Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Simple card using JS to get data

P
Hana 910

@Hanka8

Desktop design screenshot for the Expenses chart component coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

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

P
Justin Green 2,610

@jgreen721

Posted

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 helpful

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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