I'm struggling with using .map and await. How do I get the below to wait until the map has completed?
export async function buildDeviceArray(userIdList){ //userIdList is an array of ids
await userIdList.map(myFunction2)
return deviceArray1 // returns straight away, rather than waiting for the .map to complete
async function myFunction2(item) {
let user = await wixData.get("OurUsers", item)
let device = await wixData.get("Devices", user.deviceDefault)
let output = { "label": device.deviceReference, "value": user.deviceDefault }
if (user.deviceDefault) deviceArray1.push(output)
console.log(deviceArray1);
return
}