How can i process the response of a webviewer api

i found his api that can give today’s horoscope for any zodiac sign and it works fine from a browser - it returns a json response.

and when i use a webviewer in thunkable pointing to the url,
image

i also get back a json string
image

i have 2 questions:

  1. is it possible to get the response (hidden ie. not displayed) so i could parse iit a a json string and present the fields nicely in a nice page (and not in a webviewer page)?

  2. why do i get a network error when i try to use webapi on it?

image

image

NetworkError when attempting to fetch resource.

here’s the project to play with
https://x.thunkable.com/copy/ab71441300a96df382f0caaa0214ded5

1 Like

I did get an error in Thunkable Live but then I pasted the API url in again and it worked. But it’s exactly the same as what you had (I think) so I’m not sure what happened there.

You can parse the JSON response to get the horoscope or other properties. See the first screen of this demo:

https://x.thunkable.com/copy/f800285df5e0df694d27f18120bb2e45

2 Likes

Yes, you can but you have to use the Web Viewer Extension to pass info back to the app.

This means you need to test it from the mobile not the computer, I think.

[Update]

I just tested this block from Thunkable mobile app and it worked.

1 Like

I figured it out. Your API url had a space (" ") at the end. It was causing problems.

1 Like

it still fails for me on the desktop even after i removed the trailing space!

1 Like

it worked for me on my android, too. thanks!
(so much inconsistency though)

1 Like

this would be hard to test because i would have to flip back and forth betwen desktop and mobile after every change! for an app like this, it’s simple - but beyond this it would be tough!

1 Like

Unfortunately this is a platform limitation.

You can keep The Thunkable app open and showing your project in your mobile while you change the blocks in your computer and the changes will be reflected with a little delay.

1 Like

maybe it’s not so bad. i’ll play with it later. thanks!

1 Like

Many APIs don’t work in a desktop browser.

But if you test in Thunkable Live, it’s quick to see if you’re parsing it correctly or not.

2 Likes

It’s a strict CORS policy issue I’m guessing. I can’t explain it as I don’t fully understand why it’s happening. It’ll have something to do with the host website/server. I’ll ask the engineers this week if there’s anything we can do to improve that issue.

2 Likes

I will, later, create an HTML file to read the data and pass it to the Web Viewer which should solve the issue of not being able to run it from your computer.

2 Likes

i got my horoscope app working - thanks to everyone’s suggestions!
here’s the project link (remember, you can only live test on the device!)

https://x.thunkable.com/copy/19ba34af0f9b04cd8195df33ed8bd837

is there a command to terminate the application? (like a button to say ‘done’)

3 Likes

No button or blocks to “close” apps.

This is super cool! Thanks for sharing!!

1 Like

This is the actual issue for all API calls from Thunkable computer preview.

It seems Thunkable preview server blocks information including the server name. Most API service sites would not accept null as a source of request as it could be a hacking attempt.

1 Like

The same isn’t happening from published webapps is it? I think this is just an issue related to preview online?

1 Like

Have you tried it?

It didn’t work for me as a web app, either.

Thanks for turnip it here @muneer I’ll check it out today and file a bug report if it makes sense. That’s an issue if it’s happening for webapps.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.