Fetch request returns Promise

Hey , I got a country page with links to border countries , now are the border country names not the full country name so I need to make a fetch request for the full name but when I do the result becomes a Promise (see picture 1) How can I access this value? I tried to fix this with .then it gives me the correct data. But then I can't put the data inside my component (see image 2 example 2) getBorderCountryName() fetches the URL of the API GitHub code : https://github.com/Jenskiii/countriesApi-dec2023-react live site : https://countries-api-dec2023-react.vercel.app/countries/MK
GitHub
GitHub - Jenskiii/countriesApi-dec2023-react
Contribute to Jenskiii/countriesApi-dec2023-react development by creating an account on GitHub.
5 Replies
Jochem
Jochem•12mo ago
That's how fetch works. Either use the .then function or use async / await
Dries
DriesOP•12mo ago
ye but how can i put the value inside my component?
Jochem
Jochem•12mo ago
what file is this code in?
Dries
DriesOP•12mo ago
think i figured it out, ill just push the data inside an empty array wich i can access then inside the component thanks anyway 🙂
Jochem
Jochem•12mo ago
no worries 🙂
Want results from more Discord servers?
Add your server