intro-to-promises fetch() 1

intro-to-promises fetch()

  .then(response => response.json())
  .then(data => console.log(data))

Here is what the above code is Doing:
1. We’re using the fetch() method to make a request to the API.
2. We’re using the .then() method to handle the response.
3. We’re using the .json() method to convert the response to JSON.
4. We’re using the .then() method again to handle the JSON data.
5. We’re using console.log() to log the data to the console.

Similar Posts