The below function “promisall” that uses Promise.all works perfectly on frontend code in a browser but put it in backend code and it doesnt wait for the promises to be fulfilled. If am correct and it doesnt work in backend code, any workarounds or have i messed up.
export function promiseall() {
let fcaarray = ;
getarray().then((result) => {
for ( var i = 0; i < result.items.length; i++) {
fcaarray[i] = getfcainfo(result.items[i].frn);
}
Promise.all(fcaarray).then(info => {
console.log(“Here”)})
});
}
export function getfcainfo(fcanumber) {
const url = ‘URL’ + fcanumber;
return fetch(url, {
method: “get”,
headers: {
‘Content-Type’: ‘application/json’
},
})
.then(response => response.json())
}