Skip to main content

Hi everyone,

I'm working on a Zapier integration and have the following subscribeHook function. I want Zapier to display an error message to the user if the subscription request (subscribe) fails and the server returns a status code of 400 or higher.

Here's my code:

const subscribeHook = (z, bundle) => {
const data = {
// some data here
};

const options = {
url: process.env.BASE_URL + "/api/subscribe",
skipThrowForStatus: true,
method: "POST",
body: data,
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
};

return z.request(options).then((response) => {
if (response.status >= 400) {
throw new z.errors.ResponseError(response);
}
return response.data;
});
};

Problem:

When the server returns a status code ≥ 400, I want Zapier to display an error to the user. However, currently, the error message isn't appearing in Zapier as expected.

Question:

How can I modify the subscribeHook function so that Zapier displays an error when the subscription request fails? Is there anything specific I should consider regarding error handling in Zapier?

Thanks for your help!

More information:

"zapier-platform-core": "15.17.0"

// app/triggers/webhook.js
 

module.exports = {
display: {
description: "here we catch the OneClick button click",
hidden: false,
label: "Webhook Trigger",
},
key: "webhook",
noun: "Webhook",

operation: {
type: "hook",
perform: triggerData,
performSubscribe: subscribeHook,

,

 


 

Be the first to reply!

Reply