complete-javascript-course
complete-javascript-course copied to clipboard
Country API Issues while rendering (Complete Solution)
////// Instead of writing this code
<article class="country">
<img class="country__img" src="${data.flags.png}" />
<div class="country__data">
<h3 class="country__name">${data.name.common}</h3>
<h4 class="country__region">${data.region}</h4>
<p class="country__row"><span>👫</span>${(
+data.population / 1000000
).toFixed(1)} people</p>
<p class="country__row"><span>🗣️</span>${data.languages.urd}</p>
<p class="country__row"><span>💰</span>${data.currencies.name}</p>
</div>
</article>
///// Write this code
<article class="country ${className}">
<img class="country__img" src="${data.flags.png}" />
<div class="country__data">
<h3 class="country__name">${data.name.common}</h3>
<h4 class="country__region">${data.region}</h4>
<p class="country__row"><span>👫</span>${(
+data.population / 1000_000
).toFixed(1)}</p>
<p class="country__row"><span>🗣️</span>${Object.values(
data.languages
).join()}</p>
<p class="country__row"><span>💰</span>${Object.keys(
data.currencies
).join()}</p>
</div>
</article>
//////////// Also destructure data2 in request2 event handler
const [data2] = JSON.parse(this.responseText);
on chaining promises the neighbour country does not want to appear saying TypeError: Cannot read properties of undefined reading png... i dont know why is that.help please...
on chaining promises the neighbour country does not want to appear saying TypeError: Cannot read properties of undefined reading png... i dont know why is that.help please...
At line 79 change the code like this:
.then(data=> renderCountry(data[0], "neighbour"));
on chaining promises the neighbour country does not want to appear saying TypeError: Cannot read properties of undefined reading png... i dont know why is that.help please...
At line 79 change the code like this:
.then(data=> renderCountry(data[0], "neighbour"));
thanks it worked ☺
on chaining promises the neighbour country does not want to appear saying TypeError: Cannot read properties of undefined reading png... i dont know why is that.help please...
At line 79 change the code like this:
.then(data=> renderCountry(data[0], "neighbour"));thanks it worked ☺
Always Welcome, Follow me to stay in touch 😀
