> For the complete documentation index, see [llms.txt](https://doc.duaer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/integrations/builtin/core-nodes/duaer-nodes-base.code/common-issues.md).

# Common issues with Code in Duaer

Common Code node issues in Duaer: return format, import, modules, network access, credentials, and Python.
## Code does not return items properly <a href="#code-doesnt-return-items-properly" id="code-doesnt-return-items-properly"></a>

Duaer passes an array of objects between nodes, and each object’s json key points to another object. The Code node must return that shape:

```
return [
  { json: { name: 'Ada', score: 92 } },
  { json: { name: 'Lin', score: 88 } },
];
```

A json key that holds an array, no return value, or undefined all fail. For undefined, check that the fields you reference exist on every run.

## 'import' and 'export' may only appear at the top level <a href="#import-and-export-may-only-appear-at-the-top-level" id="import-and-export-may-only-appear-at-the-top-level"></a>

The Code node’s JavaScript sandbox does not support import or export. Use require instead: const lodash = require('lodash');

## Cannot find module '<module>' <a href="#cannot-find-module" id="cannot-find-module"></a>

Only a self-hosted Duaer can load extra modules in the Code node:

1. Install the module where Duaer runs. With Docker, build a custom image from your Duaer image with the module installed.
2. Set NODE_FUNCTION_ALLOW_BUILTIN (built-in modules) and NODE_FUNCTION_ALLOW_EXTERNAL (external modules) to the allowed names, then restart.

## fetch or axios fails in the Code node <a href="#no-network-access" id="no-network-access"></a>

The Duaer Code node runs in a sandbox with no network access, so fetch, axios, and http modules fail. Make the request with the HTTP Request node, then process its output in the Code node.

## The Code node cannot read credentials <a href="#cant-access-credentials-in-a-code-node" id="cant-access-credentials-in-a-code-node"></a>

By design, the Code node cannot read Duaer credentials, so secrets cannot leak. Send authenticated requests with HTTP Request. To pick credentials by condition:

- Route with a Switch node to nodes that use different credentials.
- Use Custom Auth in HTTP Request and set headers, query parameters, or body with expressions.

## Keep data between runs <a href="#using-global-variables" id="using-global-variables"></a>

Store a little data with $getWorkflowStaticData('global') or $getWorkflowStaticData('node'), such as the date of the last report. To avoid processing the same items twice, the Remove Duplicates node is simpler.

## Python errors <a href="#python" id="python"></a>

- The Python option cannot import anything unless the instance admin allows it.
- Python does not support the _ helpers, except _items in all-items mode and _item in per-item mode.
- When the instance disables Python, the node fails at once. A self-hosted admin sets DUAER_PYTHON_ENABLED to true, or removes it, and restarts.

Refer to [Python](/integrations/builtin/core-nodes/duaer-nodes-base.code.md#python-native-beta).
## Questions

### Can the Duaer Code node make HTTP requests?

No. The Duaer Code node sandbox has no network access. Use the HTTP Request node, then process the result in Code.

### Can the Duaer Code node use credentials?

No. Duaer does not let the Code node read credentials. Send authenticated calls with HTTP Request.

