Async API Call with Custom Javascript?

Is it possible to run a asynchronous api call with custom javascript using fetch (or any other method) in a workflow?

Im making an api call that takes a varying amount of time to return a response and I’m not sure if a Fetch API call is possible solution. Thank you

Yes of course, the way to write your javascript can vary if you want the next action to wait this one to be finished (and use the result of your fetch in the next workflow steps).

basically you have to put the keyword await before your fetch, and return the result if you want it to be accessible in the next steps

3 Likes

Awesome thats exactly what I was trying to setup instead of looping with a time delay.

Originally I had setup a script (using the help of AI) that gets a 200 success but doesn’t get a response from my API request. I’ll continue tinkering with it to get it working.

Is it possible to drop an example request await fetch api request in here? Im generating some with the AI and doesn’t seem to be working.

Can you share the code that’s not working? might be easier to point out the single change to fix rather than asking people to craft demos.