+ 7
Why it is not working.
I want to display news using news api. async function getNews() { let linkData = await fetch('https://newsapi.org/v2/everything?q=tesla&from=2021-07-18&sortBy=publishedAt&apiKey=e5f31f2b67f5447db48731d6b9bae9aa'); let data = await linkData.json(); for (let i of data.articles) { console.log(i.description); } } getNews();
3 ответов
+ 3
If you console log the data , it clearly says requests from browser not allowed except localhost
0
If your code is in js window it won’t work. I think sololearns blocks it. But it works if you use js inside html
I had written somthing similar using fetch. You have made some mistakes in fetch function.
https://code.sololearn.com/WelfVZv2STg4/?ref=app