fetch api get json file code example
Example 1: fetch api javascript
fetch('http://example.com/movies.json')
.then((response) => {
return response.json();
})
.then((myJson) => {
console.log(myJson);
});
Example 2: .fetch method
fetch('http://example.com/data.json')
.then(data => data);
.catch(err => console.log(err));