I encountered an issue with this line of code:
let obj = await (await fetch(url)).json();
The first time I execute the function containing this code, everything works smoothly and I receive the desired JSON response.
However, upon the second execution in the same browser session, I encounter the following error:
Access to fetch at **** from origin **** has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I am puzzled as to why this happens. If I refresh the page and try again, it works fine. But if I attempt another request without refreshing, it fails.
UPDATE: I have identified the solution. The error status code I receive is 429, indicating a Too Many Requests response status. I must wait approximately 20 seconds between each request, which can be inconvenient but necessary.