Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCraig Kempster
4,332 PointsImporting external JSON file using Native JS
I am working on a personal project where I am trying to import an external JSON array file using native Java Script, do you have any videos in the library which explain the process of reading JSON files. I do not wish to use an external library, the idea is to understand the process.
Thank you Craig
3 Answers
Craig Kempster
4,332 PointsThank you Steven, the course was an eye opener
Steven Parker
231,236 PointsIn the past this would have been a huge pain, but the relatively new native "fetch" function makes this nearly as easy to do as with jQuery:
fetch("array.json")
.then(response => response.json())
.then(obj => /* do what you want here with the JSON object "obj" */);
Note that the default security settings of some browsers might not allow loading local files from the computer.
Craig Kempster
4,332 PointsThank You Steven
Is there a JSON course in Treehouse that you are aware of?
Steven Parker
231,236 PointsNot that I know of, but there's a Working with the Fetch API workshop.
Steven Parker
231,236 PointsSteven Parker
231,236 PointsCraig Kempster - Glad to help. But normally, you'd select as "best answer" the answer that contained the information that resolved your issue.
Any comments you might want to make can be added to the question with "add comment" instead of creating another "answer".