what fetch returns code example
Example 1: fetch api in javascript
// GET Request.
fetch('https://jsonplaceholder.typicode.com/users')
// Handle success
.then(response => response.json()) // convert to json
.then(json => console.log(json)) //print data to console
.catch(err => console.log('Request Failed', err)); // Catch errors
Example 2: .fetch method
fetch('http://example.com/data.json')
.then(data => data);
.catch(err => console.log(err));