-
Notifications
You must be signed in to change notification settings - Fork 17.5k
Open
Description
/////////// Instead of this code
const getCountryData = function (country) {
// Country 1
fetch(`https://restcountries.com/v3.1/name/${country}`)
.then(response => response.json())
.then(data => {
renderCountry(data[0]);
const neighbour = data[0].borders[0];
if (!neighbour) return;
return fetch(`https://restcountries.com/v3.1/alpha/${neighbour}`);
})
.then(response => response.json())
.then(data => renderCountry(data, 'neighbour'));
};
////////////// Write this code
const getCountryData = function (country) {
// Country 1
fetch(`https://restcountries.com/v3.1/name/${country}`)
.then(response => response.json())
.then(data => {
renderCountry(data[0]);
const neighbour = data[0].borders[0];
if (!neighbour) return;
return fetch(`https://restcountries.com/v3.1/alpha/${neighbour}`);
})
.then(response => response.json())
.then(data => renderCountry(data[0], 'neighbour'));
};
Haand01
Metadata
Metadata
Assignees
Labels
No labels