Hi guys, this is my first React Challenge, nice experience.
I couldn't make the border countries' links work well, in some countries works but in others not.
If someone has a tip, I would be very grateful :3
The problem is that the API returns me the border country with just 3 letters, and when I send that to the link, sometimes, find nothing, I don't know how to get the full name of the border country :v
I've had a similar problem when I tried to display the border countries, so I implemented a function which receives a country code, goes through all countries data and returns a name of the country whose country code is equal to the one forwarded. Here it is:
function searchCountry(code) {
let name
for (let i = 0; i < countries.length; i++) {
if (countries[i].cca3 == code) {
name = countries[i].name.common
}
}
return name
}
You can use this function to display the full name of the country in your Link, rather than only the first three letters. Hope this helps, happy coding! :)