(country)
| 150 | }); |
| 151 | };*/ |
| 152 | const 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 |
| 164 | btn.addEventListener('click', function () { |
| 165 | getCountryData('portugal'); |
no test coverage detected