Calling Query that errors returning undefined

  1. My goal: So I want to upload a csv and then run every item in that file through 2 API calls. I need the response from the first API before I call the next query
  2. Issue: When the API returns a 400, it always returns a undefined. It's not an error but undefined.
  3. Steps I've taken to troubleshoot:
  1. using async
for (const row of data_from_table) {
    let apiResponseData = await provision_api.trigger({
      additionalScope: {
        id: row.id,
        extra_data_1: row.extra_data_1,
      }
    });

    // when we have a 400 returned from the API, apiResponseData is undefined.
    // therefore this is an error
    await save.trigger({
      additionalScope: {
        id: row.id
        timestamp: new Date().toISOString(),
        http_status_code: apiResponseData.http_status
      }
    });
}
  1. Promise.all
// map through every row of a csv file and call an API
return Promise.all(
  data.map((row) => {
    return provision_api.trigger({
      additionalScope: {
        id: row.id,
        extra_data_1: row.extra_data_1,
      }
  });
  }),
).then((results) => {
// results is undefined
  console.log(results);
  return results;
}).catch(error => {
  // never hit
  console.log('this');
});
  1. Additional info: (Cloud or Self-hosted, Screenshots)
    I've tried changing the failure conditions, still only getting undefined.
    Screenshot 2025-07-30 at 17.13.53

Error from API.
Screenshot 2025-07-30 at 17.11.22

Hi @jameslappin!

This sounds like some logic that might be better handled in workflows, where you can use loop blocks to make a series of API calls, have all the results stored as either undefined or some data type, then move on to the next step where you can make a number of decisions about how to pass the data into the second API call.

You could have an if block or a filtering block to remove the undefined results, you could also map over the data that was used in the call and make on object if you want to keep a reference to which calls returned undefined.

Then you can pass the data you want to another loop block to make the second set of API calls. The handling of undefined in queries in the app can be somewhat limited when making large batches of calls and is better suited for making single calls instead of using JS and Promise.all to run concurrent async queries/API requests.

Hi @jameslappin,

Just wanted to check back in on if you are still having this issue and if you got a chance to try out any of my suggestions for better error handling :sweat_smile:

Regardless of whether this could or should be done in a workflow, I think the question is still a valid one – how does one get access to the error, via apiResponseData? Clearly the global resource query has it. Shouldn’t that same error information be contained within apiResponseData ?