Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Country API Issues while rendering (Complete Solution) #436

Open
saroshkhann opened this issue Sep 5, 2024 · 4 comments
Open

Country API Issues while rendering (Complete Solution) #436

saroshkhann opened this issue Sep 5, 2024 · 4 comments

Comments

@saroshkhann
Copy link

saroshkhann commented Sep 5, 2024

////// 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);

@InnocentCode4ui
Copy link

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...
Screenshot (77)

@saroshkhann
Copy link
Author

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... Screenshot (77)

At line 79 change the code like this:
.then(data=> renderCountry(data[0], "neighbour"));

@InnocentCode4ui
Copy link

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... Screenshot (77)

At line 79 change the code like this: .then(data=> renderCountry(data[0], "neighbour"));

thanks it worked ☺

@saroshkhann
Copy link
Author

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... Screenshot (77)

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 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants