From 82733565349b15e5fab969fdf7ea8415074b95a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Mon, 13 May 2024 16:46:34 +0200 Subject: [PATCH] fix(Code Node): Bind helper methods to the correct context --- packages/nodes-base/nodes/Code/Sandbox.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Code/Sandbox.ts b/packages/nodes-base/nodes/Code/Sandbox.ts index fb8aeb5ced0ef..aab88f1b39383 100644 --- a/packages/nodes-base/nodes/Code/Sandbox.ts +++ b/packages/nodes-base/nodes/Code/Sandbox.ts @@ -19,11 +19,16 @@ export interface SandboxContext extends IWorkflowDataProxyData { export const REQUIRED_N8N_ITEM_KEYS = new Set(['json', 'binary', 'pairedItem', 'error']); export function getSandboxContext(this: IExecuteFunctions, index: number): SandboxContext { + const helpers = { + ...this.helpers, + httpRequestWithAuthentication: this.helpers.httpRequestWithAuthentication.bind(this), + requestWithAuthenticationPaginated: this.helpers.requestWithAuthenticationPaginated.bind(this), + }; return { // from NodeExecuteFunctions $getNodeParameter: this.getNodeParameter, $getWorkflowStaticData: this.getWorkflowStaticData, - helpers: this.helpers, + helpers, // to bring in all $-prefixed vars and methods from WorkflowDataProxy // $node, $items(), $parameter, $json, $env, etc.