I am trying to fetch inside a render function and have a then function that does something. My code is below. However, it doesn't seem to ever call the then function.
fetch(url, { method: "GET", headers: { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': "*", "Cache-Control": "no-store" }, body: null }) .then(function (res) {console.log("here");finished++}) .catch(function (err) {console.log(err)});
while (finished<1) {}
I have tried adding a different number of parameters to the function being passed into the then function. I have also tried adding a finally block. comments show that the async call is successful and successfully returning, so I can't fathom what the problem is. Any help would be appreciated.