UNPKG

n8n-nodes-base

Version:

Base nodes of n8n

38 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cloudflareApiRequest = cloudflareApiRequest; exports.cloudflareApiRequestAllItems = cloudflareApiRequestAllItems; const n8n_workflow_1 = require("n8n-workflow"); async function cloudflareApiRequest(method, resource, body = {}, qs = {}, _uri, headers = {}) { const options = { method, body, qs, uri: `https://api.cloudflare.com/client/v4${resource}`, json: true, }; try { if (Object.keys(headers).length !== 0) { options.headers = Object.assign({}, options.headers, headers); } if (Object.keys(body).length === 0) { delete options.body; } return await this.helpers.requestWithAuthentication.call(this, 'cloudflareApi', options); } catch (error) { throw new n8n_workflow_1.NodeApiError(this.getNode(), error); } } async function cloudflareApiRequestAllItems(propertyName, method, endpoint, body = {}, query = {}) { const returnData = []; let responseData; query.page = 1; do { responseData = await cloudflareApiRequest.call(this, method, endpoint, body, query); query.page++; returnData.push.apply(returnData, responseData[propertyName]); } while (responseData.result_info.total_pages !== responseData.result_info.page); return returnData; } //# sourceMappingURL=GenericFunctions.js.map