Skip to content

Instantly share code, notes, and snippets.

@sandrabosk
Created April 29, 2020 16:52
Show Gist options
  • Save sandrabosk/8fd7465342ff6982353ac65535ad4932 to your computer and use it in GitHub Desktop.
Save sandrabosk/8fd7465342ff6982353ac65535ad4932 to your computer and use it in GitHub Desktop.
// 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