Hello Friend,
There are a few different ways of getting the data from the JSON file.
For this challenge I used the fetch()
method.
⁄⁄ Fetch a JSON file
fetch('./data.json')
⁄⁄ Next we need to use the .then() method and the .json() method to parse the response from the fetch() method
.then((response) => {
return response.json();
})
⁄⁄ Now another .then() method
.then((data) => {
⁄⁄ We now have the parsed data in a format we can use in JavaScript
}
Honestly I struggle to explain how this works, so I'm gonna leave this here for now 😵💫