Does query.trigger() not return data results on failed query?

I have this line in my async pattern JS query:

let ctData = await restCaptionToolsAddVideo.trigger({additionalScope: {data: r}})

The query is failing (400 Bad request) and restCaptionToolsAddVideo.data is populated with the error message. However, ctData is still undefined.

Is data being returned by trigger() only on successful queries?

Bradly, yes. That's your verification, and I'm confirming too that data is only returned on successful queries. What are you looking to do that we could brainstorm a workaround together for?

I have a workaround:

let ctData = await restCaptionToolsAddVideo.trigger({additionalScope: {data: r}})
if (restCaptionToolsAddVideo.data.error) {
    //Handle Error
}

Since .trigger() returns .data on a successful query, it should also return .data on a failed query in order to keep some constancy. So this seems like a design error if not a bug.

Something like is easier to intuit:

let ctData = await restCaptionToolsAddVideo.trigger({additionalScope: {data: r}})
if (ctData.error) {
    //Handle Error
}
1 Like

Totally agree Bradly, and love that you shared this! :pray: Looking forward to the next time we meet again! :smiley: