Skip to content

Instantly share code, notes, and snippets.

@gdyrrahitis

gdyrrahitis/async.js Secret

Created Jul 10, 2019
Embed
What would you like to do?
const fetch = require('node-fetch');
const url = 'https://restcountries.eu/rest/v2/alpha/gb';
async function getCountry() {
return url
|> fetch
|> await
|> r => r.json()
|> await
|> c => {
return {
name: c.name,
capital: c.capital,
population: c.population,
flag: c.flag
}
};
}
(async () => {
const response = await getCountry();
console.log(response);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.