UNPKG

n8n-nodes-supadata

Version:

Tool for extracting content from YouTube videos and web pages

47 lines 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.supadataApiRequest = supadataApiRequest; exports.supadataApiRequestAllItems = supadataApiRequestAllItems; const n8n_workflow_1 = require("n8n-workflow"); async function supadataApiRequest(method, endpoint, body = {}, query = {}) { const credentials = await this.getCredentials('supadataApi'); if (!(credentials === null || credentials === void 0 ? void 0 : credentials.apiKey)) { throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'No API key found in credentials', }); } const options = { method, headers: { 'x-api-key': credentials.apiKey, 'user-agent': 'n8n', 'Content-Type': 'application/json', Accept: 'application/json', }, qs: query, url: `https://api.supadata.ai/v1${endpoint}`, json: true, }; if (Object.keys(body).length > 0) { options.body = body; } try { return await this.helpers.httpRequest(options); } catch (error) { throw new n8n_workflow_1.NodeApiError(this.getNode(), error); } } async function supadataApiRequestAllItems(propertyName, method, endpoint, body = {}, query = {}) { const returnData = []; let responseData; do { responseData = await supadataApiRequest.call(this, method, endpoint, body, query); if (responseData[propertyName]) { returnData.push(...responseData[propertyName]); } query = {}; } while (responseData.next); return returnData; } //# sourceMappingURL=GenericFunctions.js.map