I am learning JS and got hit with one of an issue, I am trying to call a service using a function and then over the response I am doing some processing. My expectation is function should return a value instead of the promise. I tried using await/then but none works. Can someone please point out the issue. Below is the snippet of function.
const isDeviceAnExtendedNode = async (deviceId) => {
getDevicesInfo(deviceId).then(response =>{
if(response !== undefined){
response[0].roles.forEach(role => {
if(roleType.has(role)){
console.log('has')
return false;
}})
}
})
}
Below is the calling function:
export const getFilteredDevices = (deviceList, deviceId, CedgeDeviceList) => {
const filteredDevices = [];
deviceList.map((device) => {
isDeviceAnExtendedNode(device.instanceUuid)
console.log('hello')
{
filteredDevices.push({ text: device.hostname, value: device.instanceUuid });
}
});
return filteredDevices;
}
Any help would be appreciated