# Importing multiple modules from same package

**URL:** <https://discourse.nodered.org/t/importing-multiple-modules-from-same-package/52966>\
**Category:** General\
**Created:** [30 October 2021 07:32 UTC](https://discourse.nodered.org/t/importing-multiple-modules-from-same-package/52966 "2021-10-30T07:32:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hoolahoous](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hoolahoous/32/16612_2.png) [@hoolahoous](https://discourse.nodered.org/u/hoolahoous)\
**Post date:** [30 October 2021 07:32 UTC](https://discourse.nodered.org/t/importing-multiple-modules-from-same-package/52966/1 "2021-10-30T07:32:09Z")

</div>

Hi

I am using node-red 2.0.5.  
In a function node, I am trying to import FormData and File modules form [GitHub - octet-stream/form-data: Spec-compliant FormData implementation for Node.js](https://github.com/octet-stream/form-data) package.  
i.e. i am trying to find equivalent of  
`import {FormData, File} from "formdata-node"`

Here are things I tried :

- in function node's setup, i tried this ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/5/f5a6763aef8bae817831dedd10469638402a094d.png) and in code i tried to use formdatanode.FormData but it couldn't find this object.
- then I tried this ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/354738890b1afe1a1cf112b0ef2804748b3add61.png) This didn't work either.

So what is the the right way to import ?

Second question (which is my real goal). I have a buffer object which contains a screenshot from my camera. I am trying to post it to telegram using their sendphoto rest endpoint. That requires a multipart form upload. So I am trying to send the buffer (along with content-type) and two other string parameters (chatId and caption). I could use their sdk, but I don't want to import whole SDK for just this single multiform post.

Any help will be appreciated.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [30 October 2021 08:28 UTC](https://discourse.nodered.org/t/importing-multiple-modules-from-same-package/52966/2 "2021-10-30T08:28:47Z")

</div>

> [@hoolahoous](#):
>
> Second question (which is my real goal). I have a buffer object which contains a screenshot from my camera. I am trying to post it to telegram using their sendphoto rest endpoint

Why dont you just use the telegram nodes?

Here is a working demo : [Taking a picture and sending it via telegram - #4 by Steve-Mcl](https://discourse.nodered.org/t/taking-a-picture-and-sending-it-via-telegram/27905/4)

* * *

> [@hoolahoous](#):
>
> in function node's setup, i tried this
> 
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/5/f5a6763aef8bae817831dedd10469638402a094d.png)

This does work. Did you wait long enough for the modules to download and install? Does your node-red server have internet access?

Proof it works...

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/33fe8ac0337fe1b2f840757108c24148359d1c07.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/3/c3964136192271fd7fc3943b085d8de486fb319e.png)

* * *

Lastly, why are you trying to import `got`? The http-request node uses got - you can simply use the http nodes to visually create your flow instead of trying to write everything in a function.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [29 December 2021 08:29 UTC](https://discourse.nodered.org/t/importing-multiple-modules-from-same-package/52966/3 "2021-12-29T08:29:25Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
