I don't understand .getJSON()

I’ve tried entering several API URLs as .getJSON() first argument, but I can’t find an API that won’t ask for tokens. Did I miss something? Where am I supposed to find tokens for this? And how do you guys go about finding URL’s to “GET”?

I swapped “/json/cats.json” with “https://graph.facebook.com/youtube” on FCC and even started a new CodePen with the same code, but nothing happens.

TLDR;
How do I use .getJSON()? Do I need tokens? If yes, how do I get them and apply them to my code?

Hi , can you share your codepen link where you are trying to use .getJSON()

Sorry, it was late where I am, so I posted and went to bed.

Here is something I threw together to just try and understand how this works,
https://codepen.io/rotyflo/pen/rrqOjq

I get the rest of it, manipulating the object wouldn’t be difficult if I only knew how to “get” JSON.

When I go to that URL(https://graph.facebook.com/youtube), I’m met with,
“error”: {
“message”: “An access token is required to request this resource.”,
“type”: “OAuthException”,
“code”: 104,
“fbtrace_id”: “EXRWOUurKHF”

Almost all of the API’s that are in tutorials that I’ve watch result in that.
I can’t find anything on how to get an access token and apply it to what I’m doing.

Plus, I have found one or two working API’s on this forum, but when I use them as an argument for the URL, nothing happens.

Sorry for being so wordy, and thanks for taking the time to read all of this and help!

You need a token. I’ve never used this API, but a quick google search landed me here: https://developers.facebook.com/docs/marketing-api/authentication I hope this helps!

1 Like

Thanks!! I’ll see what I can get from this. Looks like what I need!

And I finally got tokenless JSON working, too! (https://random-quote-generator.herokuapp.com/api/quotes/)

Thanks again for the token reference!!

1 Like