Rest-country-api-with-theme-switcher-using-react and tailwind CSS
Design comparison
Solution retrospective
There is much space for improvement for this solution...So I would like to get some valuable feedback...😁 I need help on the second page in "Border Countries" there is the name of the countries but we are getting three letter country code. How do get names for the countries there? If you have any method to do it please tell...Thank you so much.
Community feedback
- @jesse10930Posted over 3 years ago
Hey Saumya, your project is looking good so far! In order to get the full name of the country rather than just the 3-letter country code, you have to find the country name that corresponds to the 3-letter country code from the API.
If I'm following your code correctly, you first store all the data for all the countries in the 'country' state when the home page loads. If you pass that state as a prop down to the CardDetails component, you can loop through this data to find the 'alpha3code' that matches the 3-letter country code for your border countries, and then return the 'name' from that country instead of the 3-letter code.
If you don't want to deal with props and React Router, you could fetch and store the data from 'https://restcountries.eu/rest/v2/all' each time the CardDetails component loads, but this would slow your app down quite a bit.
Hope this helps! Happy Coding!
1@nikkuvPosted over 3 years ago@jesse10930 Thank you so much for this :) I'm working on it.
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord