MCPcopy Create free account
hub / github.com/codemistic/Web-Development / getCountryData

Function getCountryData

CountriesAPI_JS/countries.js:152–162  ·  view source on GitHub ↗
(country)

Source from the content-addressed store, hash-verified

150 });
151};*/
152const getCountryData = function (country) {
153 fetch(`https://restcountries.com/v2/name/${country}`)
154 .then((response) => response.json())
155 .then((data) => {
156 renderCountry(data[0]);
157 const neighbour = data[0].borders?.[0];
158 return fetch(`https://restcountries.com/v2/alpha/${neighbour}`);
159 })
160 .then((response) => response.json())
161 .then((xxx) => renderCountry(xxx, 'neighbour'));
162};
163//handle promise rejection
164btn.addEventListener('click', function () {
165 getCountryData('portugal');

Callers 1

countries.jsFile · 0.85

Calls 1

renderCountryFunction · 0.85

Tested by

no test coverage detected