Created
April 29, 2020 16:52
-
-
Save sandrabosk/8fd7465342ff6982353ac65535ad4932 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm i axios | |
const axios = require('axios'); | |
function getCountryDetails(name) { | |
return axios | |
.get(`https://restcountries.eu/rest/v2/name/${name}`) | |
.then(res => res.data); | |
} | |
Promise.all([ | |
getCountryDetails('spain'), | |
getCountryDetails('france'), | |
getCountryDetails('portugal') | |
]) | |
.then(res => console.log('Here is all the data: ', res)) | |
.catch(err => console.log('Something went wrong getting all the data!')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment