# Web API goes white screen after getting data

**URL:** <https://community.thunkable.com/t/web-api-goes-white-screen-after-getting-data/767358>\
**Category:** Questions about Thunkable X\
**Created:** [August 25, 2020, 8:07am UTC](https://community.thunkable.com/t/web-api-goes-white-screen-after-getting-data/767358 "2020-08-25T08:07:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![davison\_alinkair](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@davison\_alinkair](https://community.thunkable.com/u/davison_alinkair)\
**Post date:** [August 25, 2020, 8:07am UTC](https://community.thunkable.com/t/web-api-goes-white-screen-after-getting-data/767358/1 "2020-08-25T08:07:48Z")

</div>

Hi guys,  
My app is using the train company public API, and the only thing the user need to do is to enter Line name and Station name, the app will get the estimated arrival time for trains of that specific station.

I am wondering why when ever the button is pressed and the data is got from Web API, the screen goes white immediately on Thunkable Live and downloaded app in iOS.

here are my simple code, user simply enter line and sta parameter and the app call the data from [https://rt.data.gov.hk/v1/transport/mtr/getSchedule.php?line=XXX&sta=XXX](https://rt.data.gov.hk/v1/transport/mtr/getSchedule.php?line=XXX&sta=XXX) and set the data to label 1.

 ![螢幕截圖 2020-08-25 下午4.06.20](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/5/9598ffa953c28c43ca063e0ebcde8a0cfb08cfea.png)

For your ref:  
Next Train API API Specification

> **[Next\_Train\_API\_Spec\_v1.1.pdf](https://opendata.mtr.com.hk/doc/Next_Train_API_Spec_v1.1.pdf)**
>
> 48.32 KB

Anyone know how can I fix this, thanks a lot!

---

<div class="post-metadata">

**Author:** ![gobassky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/gobassky/32/77019_2.png) [@gobassky](https://community.thunkable.com/u/gobassky)\
**Post date:** [August 25, 2020, 8:38am UTC](https://community.thunkable.com/t/web-api-goes-white-screen-after-getting-data/767358/2 "2020-08-25T08:38:48Z")

</div>

White screen means that there is an error in reading of object data from the object blocks. Sometimes API responses won’t always returns consistent data. You should check if the object contain the property you are reading first using “does \_\_ contains \_\_” blocks before reading the data to prevent the white screen hang.

But for your case, I notice an error in reading the data. comparing your blocks and the PDF JSON response reference, you missed out “TKL-TKO” object before trying to read “UP”. and By the way, under “UP” there are square brackets which means you need to use list blocks to access the the items, even if there is only one item.

---

<div class="post-metadata">

**Author:** ![davison\_alinkair](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@davison\_alinkair](https://community.thunkable.com/u/davison_alinkair)\
**Post date:** [August 25, 2020, 4:11pm UTC](https://community.thunkable.com/t/web-api-goes-white-screen-after-getting-data/767358/3 "2020-08-25T16:11:44Z")

</div>

> [@gobassky](#):
>
> TKL-TKO

Thanks you so much for your information, I will have a try based on your recommendation. 🙂

---

<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:** [August 26, 2020, 2:49am UTC](https://community.thunkable.com/t/web-api-goes-white-screen-after-getting-data/767358/4 "2020-08-26T02:49:50Z")

</div>

@gobassky The “does contain” block is a great suggestion! I’ve been struggling to know whether or not I am parsing JSON data correctly but now I have a way of checking each step. Thanks!

---

<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:** [August 26, 2020, 1:15pm UTC](https://community.thunkable.com/t/web-api-goes-white-screen-after-getting-data/767358/5 "2020-08-26T13:15:35Z")

</div>

@gobassky I’m wondering if you know how to retrieve data from a JSON object that has backslashes in the property names?

Here’s the project I’m testing, as described below:

[https://x.thunkable.com/copy/bba5f49b89956f99acfa2b0c3fa66552](https://x.thunkable.com/copy/bba5f49b89956f99acfa2b0c3fa66552)

When I go to this url: [https://www.purpleair.com/json?key=52AUOV78J1OX3R2J&show=21371](https://www.purpleair.com/json?key=52AUOV78J1OX3R2J&show=21371), the formatted data I want is in response–\>results[1]–\>Stats–\>v1

 ![Screen Shot 2020-08-26 at 6.08.41 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/f/bf6c73abaef1bc2df318400e8661b4e5a783c1e2.png)

The url creates this JSON:

{“mapVersion”:“0.17”,“baseVersion”:“7”,“mapVersionString”:"",“results”:[{“ID”:21371,“Label”:“Sbirdee”,“DEVICE\_LOCATIONTYPE”:“outside”,“THINGSPEAK\_PRIMARY\_ID”:“649474”,“THINGSPEAK\_PRIMARY\_ID\_READ\_KEY”:“52AUOV78J1OX3R2J”,“THINGSPEAK\_SECONDARY\_ID”:“649475”,“THINGSPEAK\_SECONDARY\_ID\_READ\_KEY”:“Y2BNKU6L0YFESCBY”,“Lat”:38.085761,“Lon”:-122.566461,“PM2\_5Value”:“81.77”,“LastSeen”:1598446433,“Type”:“PMS5003+PMS5003+BME280”,“Hidden”:“false”,“DEVICE\_BRIGHTNESS”:“15”,“DEVICE\_HARDWAREDISCOVERED”:“2.0+BME280+PMSX003-B+PMSX003-A”,“Version”:“6.01”,“LastUpdateCheck”:1598443311,“Created”:1544549222,“Uptime”:“198480”,“RSSI”:"-66",“Adc”:“0.01”,“p\_0\_3\_um”:“13325.73”,“p\_0\_5\_um”:“3832.95”,“p\_1\_0\_um”:“766.7”,“p\_2\_5\_um”:“75.8”,“p\_5\_0\_um”:“11.79”,“p\_10\_0\_um”:“3.95”,“pm1\_0\_cf\_1”:“77.7”,“pm2\_5\_cf\_1”:“123.45”,“pm10\_0\_cf\_1”:“138.39”,“pm1\_0\_atm”:“51.02”,“pm2\_5\_atm”:“81.77”,“pm10\_0\_atm”:“91.36”,“isOwner”:0,“humidity”:“59”,“temp\_f”:“68”,“pressure”:“1009.94”,“AGE”:1,“Stats”:"{“v”:81.77, **\“v1\”:87.06** ,“v2”:80.05,“v3”:77.98,“v4”:79.71,“v5”:53.03,“v6”:11.95,“pm”:81.77,“lastModified”:1598446433467,“timeSinceModified”:119989}"},{“ID”:21372,“ParentID”:21371,“Label”:“Sbirdee B”,“THINGSPEAK\_PRIMARY\_ID”:“649477”,“THINGSPEAK\_PRIMARY\_ID\_READ\_KEY”:“W62KA2YR9E5GUYFO”,“THINGSPEAK\_SECONDARY\_ID”:“649479”,“THINGSPEAK\_SECONDARY\_ID\_READ\_KEY”:“30PAG36NS1DTWWLA”,“Lat”:38.085761,“Lon”:-122.566461,“PM2\_5Value”:“79.94”,“LastSeen”:1598446433,“Hidden”:“false”,“Created”:1544549222,“Adc”:“0.01”,“p\_0\_3\_um”:“13866.0”,“p\_0\_5\_um”:“3953.7”,“p\_1\_0\_um”:“691.52”,“p\_2\_5\_um”:“69.39”,“p\_5\_0\_um”:“9.39”,“p\_10\_0\_um”:“1.57”,“pm1\_0\_cf\_1”:“76.39”,“pm2\_5\_cf\_1”:“120.91”,“pm10\_0\_cf\_1”:“127.5”,“pm1\_0\_atm”:“50.2”,“pm2\_5\_atm”:“79.94”,“pm10\_0\_atm”:“84.3”,“isOwner”:0,“AGE”:1,“Stats”:"{“v”:79.94,“v1”:84.56,“v2”:77.66,“v3”:75.66,“v4”:77.9,“v5”:52.09,“v6”:11.78,“pm”:79.94,“lastModified”:1598446433467,“timeSinceModified”:119989}"}]}

The forum software strips out the backslashes but I’ve added them back in in the **bold** section above.

Do you know how I can access Stats → {\“v1\”} ?

I’ve tried including quotes and backslashes, including just quotes, and just using v1 by itself but they are all “undefined” even though my _does contain_ is true:

 ![Screen Shot 2020-08-26 at 6.13.47 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/a/2aeb8f3379b82a5112d1ac354e2bbd4f63b38de3.png)

And I’ve tried it with and without the _generate JSON from object_ block.

 ![Screen Shot 2020-08-26 at 6.14.44 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/e/aeef6935be42557bfabde852a6119ebefead5e69.png)

But it still returns “undefined.”

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [August 26, 2020, 5:39pm UTC](https://community.thunkable.com/t/web-api-goes-white-screen-after-getting-data/767358/6 "2020-08-26T17:39:31Z")

</div>

You forgot to use one block. Here is a working version.

 ![изображение](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/c/bc1569b8815c784ac7d9ab5450a5213a078c3914.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:** [August 27, 2020, 5:49am UTC](https://community.thunkable.com/t/web-api-goes-white-screen-after-getting-data/767358/7 "2020-08-27T05:49:08Z")

</div>

Thank you! I swear I tried that but… I must not have. It works. 🙂

---

<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, 12:24pm UTC](https://community.thunkable.com/t/web-api-goes-white-screen-after-getting-data/767358/8 "2024-11-08T12:24:36Z")

</div>


