+ 1
How do I solve a 'name not resolved' error in async await api call?
I made this code to fetch data from an api async function coinDetails(){ try { const result= await fetch (`https://crossorigin.me/https://coinmarketcap.com/api/`); const allData= result.json(); console.log(allData);}catch(error){console.log(error)};} coinDetails(); But I got an error saying 'name not resolved' on my console. Any hint on how to fix this?
2 Respostas
+ 4
Agbo Joel
I got site can't be reached when I tried 'https://crossorigin.me/', should get some kind of message or status.
Try 'https://cors-anywhere.herokuapp.com/https://coinmarketcap.com/api/'.
You also need to add await in front of result.json()
https://code.sololearn.com/W7Z7veFynuKY/#js
0
That solved it, thanks!