I’m trying to make multiple fetch calls in sequence. So the first call works just fine, however, when I try to make the second call after the first call, it throws the 500 error. I’ve Been trying to mess with the client side as well as the server side all day but just have no clue. So what I’m doing below is making two fetch calls in sequence, with just a different method and a different url.
First call (POST) that works
async func1(){
try {
// debugger;
await fetch('http://apiDomain/Ready', {
method: 'POST',
}).then((rsp) => {
if(rsp.ok) {
console.log(rsp.json());
this.func2();
}
});
}
catch (error) {
console.error(error);
alert("Error: ", error);
}
So when the func1 returns rsp.ok, then I call another call (GET), func2.
async func2(){
try {
// debugger;
await fetch('http://apiDomain/ReadySetGo', {
method: 'GET',
}).then((rsp) => {
if (rsp.ok) {
console.log(rsp.json());
}
});
}
catch (error) {
console.error(error);
alert("Error: ", error);
}
(apiDomain is an .asp.net app that is running under IIS in a dev server)
I also called func2 independently after func1 (then()) not as nested, also tried Promise.all to call both but no matter what I do, as soon as the first call returns, the second one (not only just ReadySetGo but any urls) will just throw the 500 (Internal Server Error – An Error has been occurred in IIS logs).
Not really sure why the first one returns 200 just fine but the second one always fails.
Any help would be greatly appreciated.