Widget for HTML GET?

48 views
Skip to first unread message

TonyM

unread,
Feb 20, 2019, 3:35:34 AM2/20/19
to TiddlyWikiDev
Folks,

I have a 3rd party resource that provides me with some urls that returns some values. If I place the URL in the Browser address bar I see the result.

eg
{"thanks":"Thanks from all of us at filled.count.soap for using a what3words API","crs":{"type":"link","properties":{"href":"http:\/\/spatialreference.org\/ref\/epsg\/4326\/ogcwkt\/","type":"ogcwkt"}},"words":"index.home.raft","bounds":{"southwest":{"lng":-0.203607,"lat":51.521238},"northeast":{"lng":-0.203564,"lat":51.521265}},"geometry":{"lng":-0.203586,"lat":51.521251},"language":"en","map":"https:\/\/w3w.co\/index.home.raft","status":{"reason":"OK","status":200}}

Is there a way, or could be there be a way for me to provide the URI and have the result returned in a tiddler or "text reference" that I could then interrogate?

I imagine it will need a trigger widget, and would likely be an action widget but is there an existing way?

Would it be hard or dangerous to provide such? 

If this were so, For me I can build an API connection without learning developer tricks right now (Which I will eventually).

It would also be nice if we could load anything at a URI into a tiddler. From a JSON, a Plugin Tiddler, the content of another wikis tiddler, or even a post in another platform into a tiddler.

Regards
Tony

Jeremy Ruston

unread,
Feb 20, 2019, 3:48:02 AM2/20/19
to tiddly...@googlegroups.com
Hi Tony

HTTP GET is available under Node.js via the fetch command. The way to expose HTTP GET operations to wikitext in the browser would actually be via a message because the transfer needs to be initiated at a particular time -- remember that rendering widgets should not have side effects.

But the challenges are browser security: primarily CORS, which is a mechanism introduced by browsers specifically to prevent one website from grabbing data from another one; it is necessary to avoid certain kinds of cross site scripting attacks.


Secondarily, some browsers don't permit GET requests to be made from pages loaded from file: URIs.

There are workarounds (notably something called JSONP), but the cleanest solution is to use the client-server configuration and let the server do the HTTP requests.

There is a pending patch that makes it possible for wikitext in the browser to invoke commands on the server (including fetch):


Best wishes

Jeremy.
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/98603efa-4059-4367-88bf-2b2f5b476686%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

TonyM

unread,
Feb 20, 2019, 4:03:47 AM2/20/19
to TiddlyWikiDev
Thanks Jeremy,

Before I give up on a Single file wiki solution, because it is easy to host a simple html file. A Little more details. It looks to me that some of the limitations to which you refer may not apply in this case.

The solution I want to use has 
API methods. can return JSO, GeoJSON, XML and an API Key is required.

I have already found a Working Iframe <iframe src='https://w3w.co/index.home.raft' frameborder="0" width="100%"; height="600"></iframe> for a map view

and here is a working example of the simple api call https://api.what3words.com/v2/forward?addr=index.home.raft&key=891XDNQL Click to see what is returned.

Regards
Tony
Reply all
Reply to author
Forward
0 new messages