Source: components/restmodules/DeviceRestModule.js

import isUUID from 'validator/lib/isUUID';
import { API } from '../../LocalConfiguration';
import { handleErrors, errors} from "./RestModuleAPI";

const devicePath = API + '/device';
/**
 * Device Rest API
 * @module DeviceRestModule
 */

/**
 * Fetch all devices
 * @returns {Promise<void | never>}
 */
export function fetchDeviceList() {
  return fetch(devicePath)
  .then(response => handleErrors(response))
  .then(response => response.json());
}

/**
 * Fetch only undeployed (not active) devices
 * @returns {Promise<void | never>}
 */
export function fetchUndeployedDeviceList() {
  return fetch(devicePath + '?deployed=false')
  .then(response => handleErrors(response))
  .then(response => response.json());
}