how can i make n8n run any javascript i want
Describe the issue/error/question
this is the script for example n8n code cant run
var xhr = new XMLHttpRequest();
xhr.open(“GET”, “https://bigchunges.net/api/v1/user/daily?t=” + Date.now(), true);
xhr.setRequestHeader(“Authorization”, “Bearer token”);
xhr.send();
What is the error message (if any)?
ERROR: XMLHttpRequest is not defined [line 1]
Share the output returned by the last node
ReferenceError: XMLHttpRequest is not defined
at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:1:108
at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:6:2
at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/bridge.js:485:11)
at Sandbox.run (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/nodevm.js:426:23)
at Sandbox.runCodeAllItems (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Sandbox.js:36:42)
at Sandbox.runCode (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Sandbox.js:30:62)
at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code/Code.node.js:75:39)
at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:658:51)
at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:585:68
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Information on your n8n setup
- n8n version: latest
- Database you’re using (default: SQLite): latest
- Running n8n with the execution process [own(default), main]: own
- Running n8n via [Docker, npm, n8n.cloud, desktop app]: docker