Wait for API response in workflow

I’ve encountered an issue that seems so obvious that I’m almost hesitant to ask about it. I’ve searched and I don’t see anything so I’ll just ask :slight_smile:

I have a workflow that pulls data from an API, saves that data to a state, and then does something with that data (stored as a state… My broad question is, how can I make sure I’ve gotten a response before continuing then next steps in the workflow. Is this even possible to have a async wait of sorts? Sometimes if the initial API response is slow then subsequent steps fail because there is no data available for them to do work on, I don’t like putting in delays because this doesn’t seem robust (what if the delay isn’t long enough) and inefficient (there is a delay every time even when the response is quick)

My apologies if this has been addressed before.


1 Like

In my use cases this seems to be addressed by Bubble when placing a conditional statement on the subsequent steps following API data retrieval “When Result of Step 1’s:api_data_field_retrieved is not empty”

AFAIK the delays only affect events on screen and not API/database related operations, so this won’t help even if you did add a 5-10 second delay. Try adding the conditional mentioned above and see if that fixes the issue. I’ve also noticed, even without conditionals, if I try and use a variable returned by an API in later workflow steps (ie Make changes to thing), Bubble will wait until that value is returned before attempting to commit changes. It’s possible I’ve always requested data that’s quickly accessible, and your API requests are taking longer and in turn behaving differently. I’m interested to hear from others if there is a better way to address this.

Thanks for the reply! I have never tried the conditional method you mentioned i.e.

FILTER STEP 2 IF: Step 1 - API Response is empty

My assumption was that the built-in bubble workflow logic would not wait for the API response and just filter the action. I’ll give it a try!