Urlfetch data on nightbot

Asked Feb 20, 2021·4 replies·Last activity 5 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

I have this command

!addcom !text $(urlfetch json https://mysite.com/?=usd)
output of this is
{"value":{"dollar":21.36}}

how can I make it to just output the 21.36

4 replies

Your only able to use $(urlfetch json) if the request returns valid JSON. The provided example isn't valid JSON and can't be parsed.

Try:

$(eval a=$(urlfetch json https://mysite.com/?=usd);a.value.dollar)

Thanks Aaron, what is the best way to achieve the output by just calling the urlfetch