How can I get the API output returned?

Asked Nov 8, 2024·1 reply·Last activity 1 year 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.

Quote $(urlfetch https://api.sobabear.com/happiness/random-quote)
Return {"message":"Quote fetched successfully","statusCode":200,"data":{"id":102,"content":"Just as a person who has not created wealth has no right to consume it, a person who has not created happiness has no right to enjoy it.","author":"George Bernard Shaw","description":null,"link":null}}

Response: Just as a person who has not created wealth has no right to consume it, a person who has not created happiness has no right to enjoy happiness. George Bernard Shaw

I am a beginner who knows nothing. I want to learn by seeing what has been created.

1 reply

Try:

$(eval const api = $(urlfetch json https://api.sobabear.com/happiness/random-quote); if (api.statusCode === 200) { 'Quote: ' + api.data.content + ' - ' + api.data.author; } else { 'Error fetching quote'; })