Design comparison
Solution retrospective
It's been a long time since I made the last challenge from FrontEndMentor. It was fun to make.
Still I could not figure out how to use my json file with fetch
and I tried many ways but nothing worked, so I cheated a bit and just created an object containing data.json
Community feedback
- @magdaszszPosted about 3 years ago
You fetch it like you fetch from an API. fetch('data.json') .then(res => res.json()) .then(data => console.log(data))
with this snippet you'll see that you're logging the data.
0@pierre-pellegrinoPosted about 3 years ago@magdaszsz Hey, thank you for your answer ! This is what I tried to do but Chrome gave me an error message, something like
Fetch API cannot load
.I read somewhere that Chrome blocks fetches from local files for security reasons. It should be working on others browsers but I did not try as Chrome is the only one I'm using !
0@magdaszszPosted about 3 years ago@pierre-pellegrino oh yes, you're right! I wasn't even aware of that because I work in firefox by default. Interesting...
1
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