Eval JS Get request issue

I am using $(eval var a= ‘$(urlfetch Api)’; a =(some parsing); a ) Api returns json.
But i have some issue with it. Sometimes respons has little more then 400 characters. (<=420)
And sometimes Json has ’ and ‘’ ( “title”:“What’s up people”), so i can’t capture it and eval return error.
What i can do with it?
Is there way do a GET request with JS?

You can use $(urlfetch json <link-that-returns-json>). This allows to get more than a 400 character limit. Do note that the parsing has to be short enough to post in chat.

Thank you!
Yeah, i am parsing it right, just json has some links.
Does it help with ’ " ?
P.s. Right now, i am hosting api site for that command and my Apache doesn’t see headers.

It returns it a JSON object so treat it as normal JSON.

Wow, That’s pretty cool

So can i use it without '?
like
$(eval var a= $(urlfetch json Api); a.title )

Yes that is valid, here is an example that I made for searching for a wikipedia article:

!commands add !wiki Wikipedia Article: $(eval const api = $(urlfetch json https://en.wikipedia.org/w/api.php?format=json&action=opensearch&search=$(querystring)); api.error || !api[1][0] ? 'Please add a query to the search' :${api[1][0]} - ${api[3][0]})

Notice I use api.error to check that property exists, if it does I know there is an error in the search.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.