# Failing in fetching data from web api

**URL:** <https://community.thunkable.com/t/failing-in-fetching-data-from-web-api/2296873>\
**Category:** Web API's\
**Tags:** help\
**Created:** [February 26, 2023, 6:47am UTC](https://community.thunkable.com/t/failing-in-fetching-data-from-web-api/2296873 "2023-02-26T06:47:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lynnetta00644x](https://avatars.discourse-cdn.com/v4/letter/l/f4b2a3/32.png) [@lynnetta00644x](https://community.thunkable.com/u/lynnetta00644x)\
**Post date:** [February 26, 2023, 6:47am UTC](https://community.thunkable.com/t/failing-in-fetching-data-from-web-api/2296873/1 "2023-02-26T06:47:22Z")

</div>

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.

 ![Screenshot 2023-02-26 at 11.43.54 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/5/955924a0e0115ef9137ccb71a95caba12d5ca070.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [February 26, 2023, 7:17am UTC](https://community.thunkable.com/t/failing-in-fetching-data-from-web-api/2296873/2 "2023-02-26T07:17:58Z")

</div>

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?

```auto
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.

---

<div class="post-metadata">

**Author:** ![lynnetta00644x](https://avatars.discourse-cdn.com/v4/letter/l/f4b2a3/32.png) [@lynnetta00644x](https://community.thunkable.com/u/lynnetta00644x)\
**Post date:** [February 26, 2023, 7:45am UTC](https://community.thunkable.com/t/failing-in-fetching-data-from-web-api/2296873/3 "2023-02-26T07:45:00Z")

</div>

I am using exactly [this](https://community.thunkable.com/t/solved-how-to-use-date-functions-in-thunkable-x/71693/3) 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](https://www.convertunits.com/dates/from/Feb+23,+2023/to/Feb+25,+2023) I want to pick only the difference of two dates. please have a look at this screenshot to understand it fully.

 ![Screenshot 2023-02-26 at 12.40.25 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/1/919bedcfdd4de50bed0619dd4efd419dac756afe.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [February 26, 2023, 7:47am UTC](https://community.thunkable.com/t/failing-in-fetching-data-from-web-api/2296873/4 "2023-02-26T07:47:20Z")

</div>

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:

```auto
<!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

```

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [February 26, 2023, 8:04am UTC](https://community.thunkable.com/t/failing-in-fetching-data-from-web-api/2296873/5 "2023-02-26T08:04:50Z")

</div>

I was able to get it to work using these blocks (project link: [Thunkable](https://x.thunkable.com/copy/0e1a47bbc4f03a995ba5b2af8953f797)). It parses out “2” from the response. Note that if the number of days is 1, it will fail.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/7/474181a8978bc1d9e1ecaebbe7d3d1031639fc6f.png)

---

<div class="post-metadata">

**Author:** ![VijayaKrishna](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/vijayakrishna/32/110773_2.png) [@VijayaKrishna](https://community.thunkable.com/u/VijayaKrishna)\
**Post date:** [February 26, 2023, 8:16am UTC](https://community.thunkable.com/t/failing-in-fetching-data-from-web-api/2296873/6 "2023-02-26T08:16:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lynnetta00644x](https://avatars.discourse-cdn.com/v4/letter/l/f4b2a3/32.png) [@lynnetta00644x](https://community.thunkable.com/u/lynnetta00644x)\
**Post date:** [February 26, 2023, 9:26am UTC](https://community.thunkable.com/t/failing-in-fetching-data-from-web-api/2296873/7 "2023-02-26T09:26:13Z")

</div>

I tested your blocks and it gives this error again and again.  
 ![Screenshot 2023-02-26 at 2.25.41 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/6/16f9c36ab257b62851021b04b4dbab8e91ff2842.png)  
Does it only work on a mobile device?

---

<div class="post-metadata">

**Author:** ![VijayaKrishna](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/vijayakrishna/32/110773_2.png) [@VijayaKrishna](https://community.thunkable.com/u/VijayaKrishna)\
**Post date:** [February 26, 2023, 10:11am UTC](https://community.thunkable.com/t/failing-in-fetching-data-from-web-api/2296873/8 "2023-02-26T10:11:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yuramak88u7n08](https://avatars.discourse-cdn.com/v4/letter/y/76d3ee/32.png) [@yuramak88u7n08](https://community.thunkable.com/u/yuramak88u7n08)\
**Post date:** [February 27, 2023, 6:11pm UTC](https://community.thunkable.com/t/failing-in-fetching-data-from-web-api/2296873/9 "2023-02-27T18:11:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:37pm UTC](https://community.thunkable.com/t/failing-in-fetching-data-from-web-api/2296873/10 "2024-11-08T13:37:02Z")

</div>


