# Problem using "XMLHttpRequest" in function node

**URL:** <https://community.n8n.io/t/problem-using-xmlhttprequest-in-function-node/6413>\
**Category:** Questions\
**Created:** [June 22, 2021, 4:28pm UTC](https://community.n8n.io/t/problem-using-xmlhttprequest-in-function-node/6413 "2021-06-22T16:28:42Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [June 22, 2021, 9:38pm UTC](https://community.n8n.io/t/problem-using-xmlhttprequest-in-function-node/6413/4 "2021-06-22T21:38:36Z")

</div>

I understand that but still, I would go with multiple HTTP nodes. Anyways, check the links below. They have information on how to import the HTTP module into the function node.

> [@Trying to upload a file to an HTTP endpoint](http://community.n8n.io/t/trying-to-upload-a-file-to-an-http-endpoint/4459/5):
>
> ah yes, you can use a function node and make the HTTP Request from there. This works as long as you are self-hosting. Set the env variable export NODE\_FUNCTION\_ALLOW\_BUILTIN=request-promise-native then in the function node, require the request module and made the HTTP Request using multipart/form-data. If you need help with the function node let me know. You can check the post below as well.

> [@Upload File: Multipart-formdata](http://community.n8n.io/t/upload-file-multipart-formdata/1543/4):
>
> Nice idea @Kirst , just tested it and yes. Check the example below. Keep in mind that in order to require an NPM package on the function node you have to set an env variable. By default require a module is not allowed. In the example, I used the request-promise-native module and told N8N to use it like this export NODE\_FUNCTION\_ALLOW\_BUILTIN=request-promise-native. More info about that [here](https://docs.n8n.io/#/configuration?id=use-built-in-and-external-modules-in-function-nodes). { "nodes": [ { "parameters": {}, "name": "Start", "type": "n8n-nodes-base.start"…

---

_[View the full topic](https://community.n8n.io/t/problem-using-xmlhttprequest-in-function-node/6413)._
