I have an Issue with my angular webapp.
I am trying to iterate over an array and make each time a HTTP request to obtain the ID to the Module, which is an Object:
{name:string, charge:string}
Once I have updated every Module with the new property id, I want to do some stuff with these IDs. For that I need all the IDs and cannot process each Module individually. How do I achieve that? I know, because the http.get() function within Angular is async I cannot simply paste my code after the foreach() loop.
Here is my code:
ngOnInit() {
let fit = parseFit(megafit.default.fit);
fit.modules.forEach(Module => {
this.http.get(`https://esi.tech.ccp.is/v2/search/?categories=inventory_type&search=${Module.name}&strict=true`)
.subscribe((data:any) => {
Module.id = data.inventory_type
})
});
// Do something with all the IDs
}