I’m creating an integration that interacts with a REST API. I’ve built a search action that wraps an API endpoint. If a resource isn’t found, the API returns a 404.
I’m trying to test for a 404 error then return an empty array. For some reason, this doesn’t work:
return z.request(options)
.then((response) => {
if (response.status === 200) {
// a search action requires an array to be returned, so wrap with s]
return response.jsonr'data'] ];
}
else if (response.status === 404) {
return ];
}
else {
response.throwForStatus();
}
});
What am I missing?