Hi,
I was trying to make an API call with Tiddly.
What i have done is created a simple Express application that sets up a server.
http://localhost:3000/status,
I can see the result on the web. Also tested with Postman as well.
Using Tiddly also, I am getting the response in the network tab. Can anyone guide me to get the value inside the macro, meaning that I want to print the JSON value below the button that I have rendered?
Thanks,
At the bottom of WidgetMessage: tm-http-request, are three examples. Can you check first if these offer the guidance you need?
If not, I’m sure there’s someone here who can help answer specific questions.
I checked the same…but didn’t understand that fully
Disclaimer: I never used this kind of code, so I may well mislead you…
The code you’re showing in your example doesn’t define the completion-get-json macro/procedure.
The documentation for the tm-http-request message states that the response data will be available as a data variable in the “oncompletion” handler (the completion-get-json macro/procedure for you).
You might be able to get a result with something like this (not tested):
\procedure completion-get-json()
<$action-setfield $tiddler="data-request-result" $field="text" $value=<<data>>/>
\end
The data returned by the server should be in a new tiddler named data-request-result.
Hope this helps,
Fred
Example to get the json value for a dynamic table:
It is based on the source code of this tiddler https://tiddlywiki.com/#WidgetMessage%3A%20tm-http-request%20Example%20-%20Random%20Dog