How Can I Use a 'Do While' Loop to Retrieve Over 9k Records from an Airtable Base Using a Web API Without Getting a Syntax Error?

This topic was automatically generated from Slack. You can find the original thread here.

Hello Pipedream. I’m trying to get records from an airtable base with an airtable web api call. The web api lets me get 100 records at a time, and I have 9k some I’d like to grab and do things with. Airtable paginates them so that’s great. I’d like to use a do while loop for this, but I get a syntax error when I try it. As a test, I switched to a for of loop and that works fine. I can’t make heads or tails of the syntax error I’m getting.

I’ll paste my code for both loops in the comments as well as the syntax error. Any help is greatly appreciated!

The do while loop

The for of loop that works

Here’s the error I get when I run the do while loop:

Expected ',' or '}' after property value in JSON at position 65

Thanks All!

Add logs in the code to see where execution reaches before breaking.

Without running, I think the issue might be that you need to await the loop in the do-while like you did for the for-loop. Possible, the offset value hasn’t loaded.

It looks like it successfully run twice, then breaks if I instrument the do while. The offset value appears to be loading, but perhaps you’re right and I need to await something else.

When you say “await the loop in the do-while” how do you mean? You can’t await do.... correct?