UNPKG

@luka-cat-mimi/n8n-nodes-feishu-project

Version:

飞书项目 N8N 集成插件,支持附件管理等功能

36 lines 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class RequestUtils { static async originRequest(options) { const credentialName = 'feishuProjectApi'; const credentials = await this.getCredentials(credentialName); options.url = `https://${credentials.baseUrl}/${options.url}`; return this.helpers.requestWithAuthentication.call(this, credentialName, options); } static async request(options) { if (options.json === undefined) options.json = true; return RequestUtils.originRequest.call(this, options).then((data) => { var _a, _b; const handleResponse = (response) => { var _a, _b; let isNormalCode = (response === null || response === void 0 ? void 0 : response.err_code) === 0 || ((_a = response === null || response === void 0 ? void 0 : response.error) === null || _a === void 0 ? void 0 : _a.code) === 0 || ((_b = response === null || response === void 0 ? void 0 : response.err) === null || _b === void 0 ? void 0 : _b.code) === 0; if (isNormalCode) { return response; } throw new Error(`[${options.method}]${options.url} [req]${JSON.stringify(options === null || options === void 0 ? void 0 : options.body)} [res]${JSON.stringify(response)}`); }; const isExpireCode = ((_a = data === null || data === void 0 ? void 0 : data.err) === null || _a === void 0 ? void 0 : _a.code) === 10022 || (data === null || data === void 0 ? void 0 : data.err_code) === 10022 || ((_b = data === null || data === void 0 ? void 0 : data.error) === null || _b === void 0 ? void 0 : _b.code) === 10022; if (isExpireCode) { return RequestUtils.originRequest.call(this, options).then((res) => { return handleResponse(res); }); } return handleResponse(data); }); } } exports.default = RequestUtils; //# sourceMappingURL=RequestUtils.js.map