n8n-nodes-base
Version:
Base nodes of n8n
27 lines • 830 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.twistApiRequest = twistApiRequest;
const n8n_workflow_1 = require("n8n-workflow");
async function twistApiRequest(method, endpoint, body = {}, qs = {}, option = {}) {
const options = {
method,
body,
qs,
uri: `https://api.twist.com/api/v3${endpoint}`,
json: true,
};
if (Object.keys(body).length === 0) {
delete options.body;
}
if (Object.keys(qs).length === 0) {
delete options.qs;
}
Object.assign(options, option);
try {
return await this.helpers.requestOAuth2.call(this, 'twistOAuth2Api', options);
}
catch (error) {
throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
}
}
//# sourceMappingURL=GenericFunctions.js.map