export async function getInventoryCounts()

in employee-ui/src/utils/Server.js [33:51]


export async function getInventoryCounts() {
  console.time('getInventoryCounts')
  const url = process.env.VUE_APP_INVENTORY_SERVICE_URL+"/getAvailableInventory";
  const response = await fetch(url, {
    mode: 'cors',
    method: 'GET',
  })
  if (!response.ok) {
    const message = `An error has occured: ${response.status}`;
    console.log(message);
    return JSON.parse("[]");
  }
  const inventoryCounts = await response.json();
  console.timeEnd('getInventoryCounts')
  return inventoryCounts.map(ic => ({
    id: ic.ItemID,
    inventory: ic.Inventory
  }));
}