n8n-nodes-base
Version:
Base nodes of n8n
33 lines • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.humanticAiApiRequest = humanticAiApiRequest;
const n8n_workflow_1 = require("n8n-workflow");
async function humanticAiApiRequest(method, resource, body = {}, qs = {}, option = {}) {
try {
const credentials = await this.getCredentials('humanticAiApi');
let options = {
headers: {
'Content-Type': 'application/json',
},
method,
qs,
body,
uri: `https://api.humantic.ai/v1${resource}`,
json: true,
};
options = Object.assign({}, options, option);
options.qs.apikey = credentials.apiKey;
if (Object.keys(options.body).length === 0) {
delete options.body;
}
const response = await this.helpers.request(options);
if (response.data && response.data.status === 'error') {
throw new n8n_workflow_1.NodeApiError(this.getNode(), response.data);
}
return response;
}
catch (error) {
throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
}
}
//# sourceMappingURL=GenericFunctions.js.map