[Solved] Why do I see “Failed to fetch data. Please test on a device” when using the web API component in live preview (worked on Thunkable live app but not on browser live/preview mode)?

I have searched all the topic about WebAPI component, however, none of the topics found solving my problem so I post it here for sharign the case.
I used Thunkable webApi component to demo a case of sending web API to my local blynk server.
The api url was a simple get request using following format
WebIpi.url = http://localhost:8041/token/get/v1?
with curl, the response was fine with [“0”] or [“1”] when I change the status of the virtual pin using touch button. however, with thunkable, this failed and the response error was “Failed to fetch data. Please test on a device or contact support”
I tested similar code block with kodular and it work fine.
So I finally double that the WebApi component in thunkable was problematic.
Can Thunkable Devel team help to solve this with thanks.
Sincerely yours

1 Like

Did you test on the companion app? Also a link to yoir project would be helpful :grinning:

The message literally says, test it from your phone. Did you do that?

2 Likes

Hey @ngocddt2f11o Welcome to the community. This is a common issue and is due to the settings of the resource you are attempting to access and how api calls are executed from the Thunkable builder. All platforms do these actions slightly different.

Please see this article for more info

2 Likes

Sorry All from late replying. I and my family went to the countryside and busy with other work then.
My case was verry simple that I am surely, realize that it was (may be intentionally) a Thunkable drawback vs Kodular orr Mit App, at least on WebApi component. let see the code block:


If I changed the response to status or error, the error message appear. Since Thunkable only allow 2 export to Apk per month, I did try to export once but I could not do that successfully, every time I clicked on the link that Thunkable created over email, a screen just popped up and close without nothing.
The above oode blocked has tested successfully on both Kodular and Mit App via companion.
Thank you for your attention.

1 Like

The thing is you don’t need to compile to APK. You just need to install the Thunkable Companion App and then run your project from it without the need to compile.

Muneer,
Thanks for following up! I tested on thunkable live and it worked. Previously I tested all on the web live test and preview mode (all other demo cases were okay).
So it done, the topic can be closed, but I need to change the topic title first!

1 Like