How to use tm-http-request to fetch data from sites into TiddlyWiki?

I changed the url in the first example from https://tiddlywiki.com/#WidgetMessage%3A%20tm-http-request%20Examples to https://google.com. It does not seem to work. I get a XMLHttpRequest error code: 0 error. Tried a few other sites - same result. They all open fine in a web browser. What am I doing wrong here?

1 Like

Maybe it is CORS error, Google ban most request send from other domain like tiddlywiki.com. Otherwise people can embed google in any website to create their own search engine, and steal user input like google password on their site.

Anyway, you can use GitHub - tiddly-gittly/Browser-Extension-Tiddlywiki-Collector: Clip web contents into TiddlyWiki (NodeJS Ver./TidGi APP) and use TiddlyWiki as a bookmark. to collect data and send to your wiki.

Chrome and Chrome based web browsers on Android do not support extensions. Also, I’m using a single HTML file wiki, not the NodeJS version.

You need to tell us, what you expected that should happen?

The first example uses url="https://httpbin.org/get" which is designed to be accessed with a GET request. If you have a look at the docs you will see how a request to the /get path is handled.

Can you show us some documentation, what should happen if you request goolge.com with GET? Then we can tell you what went wrong. – Most likely google.com is not configured to be accessed that way.

There are some google services, which you can access with tm-http-request, but for most of them you will probably need an access token and an API description.

Can you show us some documentation, what should happen if you request goolge.com with GET?

I expected to get some HTML content as reply. Or at least a sane error message.

I did some more tests. There seems to be a “crash” somewhere which is not catched – hence no error message.

https://google.com does send a 301 (permanent redirect) to https://www.google.com

So directly requesting https://www.google.com should do 1 GET request instead of 2. Working with single step does respond with HTML file. But not, what you’d expect.

So even if google would send something back, I doubt it would be useful. To get a useful response, we would need to use the API, which is designed to give something back.

More investigation needed

Shouldn’t this get reflected in the output in TiddlyWiki?

Not for me. I get the same error if I use url="https://www.google.com". Maybe it’s Android specific?

But not , what you’d expect.

I am fine with anything that’s different than nothing. Even something similar to what google returns if I’m using a simple HTTP client like wget.

No. TW does not see it. It is handled by native XHR directly.

That’s not possible. WGET and browser XHR requests are completely different things.

The main problem is the Same Origin Policy that is active in all browsers, which should help to prevent Cross Site Scripting attacks.

The Same Origin Policy is absolute, it can only be bypassed with Cross-Origin Resource Sharing (CORS) which is deactivated if you access google.com directly.

CORS needs to be activated server side.


I did test the tm-http-request from the OP with the Edge browser. There is the same native error message. It just looks a bit different. There is no possibility to debug this any further. It seems to be browser native.