0

First time working with API's, I have added the code of my fetch call below.

I wish to grab the data from the json file to then use within JS / Vue.js to populate data (price, age, size, make, etc) for a listings page.

I have managed to get the data in to show in the console however when trying to save this to a variable after then .then I don't manage to do this correctly and unsure as to where I have gone wrong?

fetch("./example.json")
    .then(response => {
     return response.json();
})
   .then(data => {
   console.log(data); 
})
    .catch(error => {
    console.log(error);
});

The above code brings the JSON data in to my console.

My end point is to use the data from the JSON file to populate listing info for each objects data within the array in the json file.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

0 Answers0