Length of list is incorrect

I’m redesigning an old app according to a dribbble shot:

This is what it looks like:

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;


2 Likes

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?

2 Likes

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

1 Like

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

1 Like

1 Like

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

1 Like

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

1 Like

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.

1 Like


Adding this code hangs the page. If I remove it everything works as normal. Could you please provide some example code? Thanks

1 Like

I was referring to something like this

1 Like

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

1 Like

@codeswept Which url are you using from the documentation?

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

1 Like

Thanks for sharing these two pics.

1 Like