Importing multiple modules from same package

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 package.
i.e. i am trying to find equivalent of
import {FormData, File} from "formdata-node"

Here are things I tried :

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.

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


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


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.

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