I have an array of id's and I am trying to iterate over that array to make an api call for each id present. However my api call doesnt seem to be going through can anyone provide some insight?
the array of id's looks something like this:
["provider-e44f1ccd-839c-413b-9559-0d2b359ee541", "provider-1cd9c1fe-de26-4b44-a1b9-03e6fc103ac4", "provider-1cd9c1fe-de26-4b44-a1b9-03e6fc103ac4", "system", "system", "provider-1cd9c1fe-de26-4b44-a1b9-03e6fc103ac4"]
my function to make the call looks like this :
useEffect(() => {
const loadProvider = async () => {
if(entries.length > 0){
const providerID = entries.map((entry => entry.createdBy))
console.log(providerID)
try{
const results = await api.Providers.get(providerID[+i])
console.log(results, "12345678987654321")
}catch(err){}
}
};
loadProvider();
}, [entries]);
I am able to get inside the try statement but only one call is returned when i console results
I also tried using to map over entries inside the try statement but I got a syntax error for my await result variable.