The Fetch API provides an interface for fetching resources (including across the network). It will seem familiar to anyone who has used XMLHttpRequest, but the new API provides a more powerful and flexible feature set. In this challenge we will use fetch to request url and APIS. In addition to that let us see demonstrate use case of promises in accessing network resources using the fetch API.
The Fetch API provides an interface for fetching resources (including across the network). It will seem familiar to anyone who has used XMLHttpRequest, but the new API provides a more powerful and flexible feature set. In this challenge we will use fetch to request url and APIS. In addition to that let us see demonstrate use case of promises in accessing network resources using the fetch API.
```js
```js
const url = 'https://restcountries.eu/rest/v2/all' // countries api
const url = 'https://restcountries.com/v3.1/all' // countries api
fetch(url)
fetch(url)
.then(response => response.json()) // accessing the API data as JSON
.then(response => response.json()) // accessing the API data as JSON
.then(data => { // getting the data
.then(data => { // getting the data
@ -219,7 +219,7 @@ Let us fetch API data using both promise method and async and await method.