Failing in fetching data from web api

Hi all, I am facing an issue while fetching data from api. Below are the blocks I have used and I get nothing in the text input after I press the button. The issue is most likely in the api response, because when I show webapi12 text in text input it shows correctly but with the following blocks I dont see anything in the text input. Please help many thanks.

Please post the full JSON response as text and also let us know what you expect the correct parsing to be (that is, what should Text_Input1’s Text show if it works?).

Edit: Is this an example of a url I might use for this?

https://www.convertunits.com/dates/from/Feb+23,+2023/to/Feb+25,+2023

If so, it’s not returning JSON so I don’t know how you can use that with the Web API blocks in Thunkable. You would need to use an API that returns a JSON response.

Edit #2: Okay, I suppose this is possible but it’s a pain to parse the response. You can search for “there are” or “there is” which preceeds the number of days and search for “days” which comes right after that… I didn’t see <big> in the response on my mobile device.

I am using exactly this tutorial and an answer from bymaho.
The exact url is this:

https://www.convertunits.com/dates/from/

These are the dates from date pickers in thunkable Feb+23,+2023/to/Feb+25,+2023 that I pass to url but thunkable doesn’t give months in “jan” or “feb” format that’s why I am using this logic. And from here I want to pick only the difference of two dates. please have a look at this screenshot to understand it fully.

Okay, but that’s not the response that Thunkable is getting. When you assign the green [response] block to a label, you can see it’s different. So you need to parse the response rather than the page source you have in your screenshot.

Here’s an example of the response in Thunkable:

<!DOCTYPE html> <html><head><title>Number of days between February 23rd, 2023 and February 25th, 2023</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="HandheldFriendly" content="true" /> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" /> <meta name="title" content="Number of days between February 23rd, 2023 and February 25th, 2023" /> <meta name="description" content="Use the date calculator: There are 2 days between the two calendar dates, 2/23/2023 and 2/25/2023." /> <style>*{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}body{padding:0;margin:0 10px 0 0;font-family:"Roboto",Arial,sans-serif;color:#333}.leftcontent{width:0;background:#FFF;border:none;text-align:left}.left_news{position:relative;margin:0;width:0;background:#FFF}#div-gpt-ad-1494035372037-0{width:0;height:0}#div-gpt-ad-1615399

I was able to get it to work using these blocks (project link: Thunkable). It parses out “2” from the response. Note that if the number of days is 1, it will fail.

I tested the code given by Lynnetta with the join block on my phone and it worked. I think it can only be tested on a phone for some reason. It fetched the response we just have to get the difference by using tatiang’s code

I tested your blocks and it gives this error again and again.
Screenshot 2023-02-26 at 2.25.41 PM
Does it only work on a mobile device?

Yes, for me your join block code (The one where you joined Date inputs from the user together) along with Tatiang’s way to get the result from the response worked only on mobile device

1 Like

also checked out your blocks. But here the error did not disappear