This seems like it should be easy, but has anyone used variables they define as part of the URL in urlfetch? I can’t seem to get it to work.
Something like:
$(eval
const topic=“12”;
response = $(urlfetch json https://opentdb.com/api.php?amount=1&category=$(topic)&difficulty=easy&type=multiple&encode=url3986);
…
)
I also tried putting an eval nested in the urlfetch, but that doesn’t seem to embed the string.
$(eval response =$(urlfetch json $(eval topic = ‘$(1)’; my_url = “https://opentdb.com/api.php?amount=1&category="+topic+"&difficulty=easy&type=multiple&encode=url3986”; my_url)); s = JSON.stringify(response); )
Is the problem here that I don’t have access to $(1) from the embedded eval?
I’ve tried many different methods to access ‘topic’, but none seem to work. Help?