UNPKG

n8n-nodes-base

Version:

Base nodes of n8n

32 lines 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.yourlsApiRequest = yourlsApiRequest; const n8n_workflow_1 = require("n8n-workflow"); async function yourlsApiRequest(method, body = {}, qs = {}) { const credentials = await this.getCredentials('yourlsApi'); qs.signature = credentials.signature; qs.format = 'json'; const options = { method, body, qs, uri: `${credentials.url}/yourls-api.php`, json: true, }; try { const response = await this.helpers.request.call(this, options); if (response.status === 'fail') { throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Yourls error response [400]: ${response.message}`); } if (typeof response === 'string' && response.includes('<b>Fatal error</b>')) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Yourls responded with a 'Fatal error', check description for more details", { description: `Server response:\n${response}`, }); } return response; } catch (error) { throw new n8n_workflow_1.NodeApiError(this.getNode(), error); } } //# sourceMappingURL=GenericFunctions.js.map