Design comparison
Solution retrospective
Hi guys! I was not able to fetch local JSON file due to CORS policy, so I had to hardcode data to my app.js. Any suggestions for this problem? How is possible to fetch data from local JSON file without CORS errors?
Community feedback
- @jgreen721Posted over 2 years ago
My guess is you worked on this thru files (IE, copied path into the browser) which will hit a CORS error since it requires http(s). So, as is now on github or (for development, live-server VS-code extension is pretty popular), fetch("filepath/to/yourdata.json") should work. Since data.json is on same level then fetch("data.json") should be good to go. But ya, my guess was it was a File/Http issue. And if not, well, then I dunno! lol. Good job on everything else!
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord