-1

I've been calling the same API but with different ids using loop.

However I get a CORS error.

This is more of an overview of what my code looks like:

getRequest(id:string) {
    return this.http.get(url+id, options);
}
tableOfIds = [...];

storeData = [];
tableOfIds.forEach(id => {
    this.serv.getRequest(id).subscribe(elements => {
        storeData.push(elements);
    });
});

Is there a way I can call a GET request (multiple times, with different parameters) without getting a CORS error?

hc_dev
  • 8,389
  • 1
  • 26
  • 38
WattMonki
  • 29
  • 3
  • 8

1 Answers1

-2

CORS are Cross-Origin Resource Sharing used in controlling api calls from unfamiliar domains, is highly unlikely that it is caused by the loop. Check how to bypass cors in your application or tell the backend person to enable CORS in his app.

Tochukwu Ogugua
  • 111
  • 1
  • 2
  • 9