So I’ve created a javascript (embedded into an html page) with a similar functionality to the “Stay Hydrated Bot” and I’ve been trying to use it with Nightbot. HTML Javascript
Now I’ve stumbled upon the following problem.
When I call the API through my browser it works perfectly fine.
But when I try calling it using $(urlfetch) instead of using the result it fetches the entire html code and runs out of characters.
I’ve compared what I made to others and realized that their actual content of the webpage is just the result instead of an html page. I couldnt figure out a way how to get that to work for me.
Alternatively, a way to make jquery work in $(eval) would work as well
Can anyone help me out with that?
(Sidenode: I’m rather new to Javascript and creating APIs)
The $(eval) variable executes the $(urlfetch) result as raw JS. Unfortunately as it is right now, this command setup wouldn’t work because $(eval) doesn’t support jQuery. I noticed you’re using jQuery to get a result from the DecAPI uptime endpoint. To work around having to use jQuery, you could set up a $(twitch) variable inside $(eval) to get the uptime as a string “uptime”, then rewrite wasser.js to handle the output for Nightbot’s response using “uptime”.
To actually write a custom API that works with Nightbot, typically you would write something in a server-side scripting language, for example PHP, that returns only a plain text result.