I think I am having a timing issue here with how I am using async/await. I want to loop through the foo
array and make an api call and after those have all run, I want to return
the last subscribeToService
from the forEach
. I know it gets overridden each time but that is fine.
async function myFunction() {
let foo = await makeFirstCall();
foo.forEach(x => {
if (!x.isEnabled) {
const { subscribeToService } = await api.subscribeEndpoiint(
x.id,
x.name,
JSON.stringify(x.name.toJSON()),
);
}
});
return subscribeToService;
}