Source: components/restmodules/DeviceRestModule.js

  1. import isUUID from 'validator/lib/isUUID';
  2. import { API } from '../../LocalConfiguration';
  3. import { handleErrors, errors} from "./RestModuleAPI";
  4. const devicePath = API + '/device';
  5. /**
  6. * Device Rest API
  7. * @module DeviceRestModule
  8. */
  9. /**
  10. * Fetch all devices
  11. * @returns {Promise<void | never>}
  12. */
  13. export function fetchDeviceList() {
  14. return fetch(devicePath)
  15. .then(response => handleErrors(response))
  16. .then(response => response.json());
  17. }
  18. /**
  19. * Fetch only undeployed (not active) devices
  20. * @returns {Promise<void | never>}
  21. */
  22. export function fetchUndeployedDeviceList() {
  23. return fetch(devicePath + '?deployed=false')
  24. .then(response => handleErrors(response))
  25. .then(response => response.json());
  26. }