Hi Everyone,
I’m stuck on video: Project- Building a Video Games Discovery App- Fetching the Games.
here’s the error message showed on the browser:
Access to XMLHttpRequest at ‘https://api.rawg.io/api/games?key=ee56abc41bf2421fa1df42aabed3xxxx ’ from origin ‘http://localhost:5173 ’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Thank you for your help /\
Hi,
I’ve found the problem.
The problem is on my RAWG’s API account, The Number of requests left for the period is -2412.
Note:
I think because I forgot to put dependency when calling useEffect()
You can try creating a new account, don’t forget to add the square brackets in useEffect previously.
Jim
May 23, 2023, 1:14am
4
I’m having the same issue, i created a new account but looks like its going the same direction.
Could anyone provide a code snippet of the effect hook usage in this project? Or let me know how/why my app is firing so many requests to the API?
Thanks,
Jim
Like mentioned above you may not be passing the square brackets[]
as an optional second parameter to your effect hook. If you don’t include that it can run infinitely.
It’ll be something like useEffect(() => {...}, []);
Jim
May 28, 2023, 10:40am
9
yep found it, thanks mate!
1 Like