Can't get getJSON/News API to work

I had created a previous post but the post was closed before I could follow up.
(previous post: https://www.wix . com/velo/forum/coding-with-velo/how-to-grab-news-from-a-website )

I checked out the sources the Yisrael graciously provided, and they were very helpful but I am still having some trouble. On my website, I have a slider and inside the slider, I placed this code which is using the News API website.

(News API: https://newsapi . org/docs/endpoints/top-headlines)

getJSON ( https://newsapi . org/v2/top-headlines?sources=bbc-news&apiKey=<THIS IS WHERE I PUT MY API KEY> )
. then ( json => {
console . log ( json )
$w ( ‘#text28’ ). text = json . articles ;
});

It feels like I am missing something obvious, but I’m not one hundred percent sure what. I know for a fact it’s not the slider function event because I have other working code in there. And I have the import { getJSON } from ‘wix-fetch’ ;
at the top of the page outside of a function.
This is my first time working with an API and getJSON, excuse my ignorance.

What do you see in the console from the console.log(json) statement? Are you getting results?

What is json.articles? Is it really text? Or is it an array or object containing a bunch of articles? If so, you might be able to display the articles in a Repeater .

Shoot I just realized what the problem is. It’s not letting me do it because it wont allow requests from browser except on localhost : ((
I’ll have to find another free news API. Thanks anyway. Sorry for this extremely stupid question.

Umm, not such a stupid question…

Only from localhost ? What kind of API is that? Did you try accessing the API from backend code? That’s the most reliable, and most secure, way to access 3rd party services.