# Length of list is incorrect

**URL:** <https://community.thunkable.com/t/length-of-list-is-incorrect/1504543>\
**Category:** Questions about Thunkable X\
**Created:** [September 14, 2021, 10:36am UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543 "2021-09-14T10:36:11Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [September 14, 2021, 10:36am UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/1 "2021-09-14T10:36:11Z")

</div>

I’m redesigning an old app according to a dribbble shot:  
[![](https://cdn.dribbble.com/users/4601337/screenshots/15921850/media/11b4d473412c41b7c6dcba64d48914bd.png) ](https://cdn.dribbble.com/users/4601337/screenshots/15921850/media/11b4d473412c41b7c6dcba64d48914bd.png)

This is what it looks like:

 ![Screen Shot 2021-09-14 at 2.43.26 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/1/a121ad53d0812bce3901cc2d9d6d564039b43c3d.jpeg)

I’m using the MealDB API. However, the correct number of ingredients just won’t appear. Sometimes, I see the same ingredient repeated 20 times, with the ingredients starting at 1 and increasing by one with each DVL display. Other times, every single display has 22 ingredients, which isn’t correct.  
Here’s my code;

 ![Screen Shot 2021-09-14 at 2.45.49 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/6/76f258d2cda33077608e15c725f745b017aa21d9.png)  
 ![Screen Shot 2021-09-14 at 4.05.43 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/a/5aa9e9831b6db0b26db51828a02a33e6dcbbe09d.png)

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [September 14, 2021, 11:13am UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/2 "2021-09-14T11:13:03Z")

</div>

I figured out the issue but can’t think of any way to rectify it. So basically I had created a list with all the letters of the alphabet. I wanted to loop through those letters and put them one-by-one into the search MealDB by first letter API. I’m not sure for the j loop probably is asynchronous or something and looping through 26 letters and then calling an API 26 times was probably too much for the app. When I tried searching only by letter a, I was able to see all the ingredients and names properly. When I tried searching by a then b (just 2 letters), the app mixed them all up and then wasn’t able to find the correct number of ingredients. Any suggestions?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 14, 2021, 11:27am UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/3 "2021-09-14T11:27:32Z")

</div>

I’m trying to follow the code but the two images are distracting my vision.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [September 14, 2021, 11:31am UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/4 "2021-09-14T11:31:24Z")

</div>

Sorry about that! Let me resend it in two posts.

 ![Screen Shot 2021-09-14 at 2.45.49 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/6/76f258d2cda33077608e15c725f745b017aa21d9.png)

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [September 14, 2021, 11:31am UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/5 "2021-09-14T11:31:41Z")

</div>

![Screen Shot 2021-09-14 at 4.05.43 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/a/5aa9e9831b6db0b26db51828a02a33e6dcbbe09d.png)

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 14, 2021, 11:48am UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/6 "2021-09-14T11:48:38Z")

</div>

Remember that `create row` is an asynchronous block which means, if your loops are fast enough you will be mixing values.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [September 14, 2021, 1:20pm UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/7 "2021-09-14T13:20:29Z")

</div>

Ohhh, I forgot about that. So how can I rectify it?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 14, 2021, 1:32pm UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/8 "2021-09-14T13:32:21Z")

</div>

I would say that you need a variable that you set to `null` with every start of the main loop and in the `create row` block set the variable to the `row id` returned by the block. In your loop you need a wait loop to check that the control variable is not null which means the create row operation is completed.

I hope you get what I mean because I was just brain dumping.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [September 14, 2021, 2:16pm UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/9 "2021-09-14T14:16:12Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/f/5f19182ce777ba5ea4007cbee86b36b2c7fcdce7.png)  
Adding this code hangs the page. If I remove it everything works as normal. Could you please provide some example code? Thanks

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 14, 2021, 3:12pm UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/10 "2021-09-14T15:12:33Z")

</div>

I was referring to something like this

> [@Is there a wait until block?](https://community.thunkable.com/t/is-there-a-wait-until-block/1484665/6):
>
> I would do something like this [image] Although in practice I will also exit the loop after some seconds even if the control flag is still false.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [September 14, 2021, 3:35pm UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/11 "2021-09-14T15:35:35Z")

</div>

Thanks for the link! I tried it but’s still getting mixed up. Here’s my code:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/a/bab21ba06c1b0ac9345477f629c52df34d894f10.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:** [September 14, 2021, 10:40pm UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/12 "2021-09-14T22:40:56Z")

</div>

@codeswept Which url are you using from [the documentation](https://www.themealdb.com/api.php)?

And which property is not getting counted correctly? Is it “stringredient” or something else?

---

<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:15pm UTC](https://community.thunkable.com/t/length-of-list-is-incorrect/1504543/15 "2024-11-08T13:15:14Z")

</div>


