How to modify node-red deploy operation to save flow to database


Can you please guide me how can i call my external get and post api from flows.js file?


Please rephrase your question. Or explain what you are trying to do.

I am trying to call some api which is in another portal i have from flows.js file .
But i am not getting how should i write the syntax for calling get ,post and put api. please help me out.

which is in another portal i have from flows.js file .

What do you mean with this ?
Calling an API can be done with the http request node. See documentation "HTTP requests"

Is this the same problem as this thread

Watch this

Then give it a go.

If you get stuck, ask a specific question (in this thread - don't start another thread) & post screenshots and your flow & we will help you.

I am trying to call my api like this but could not getting how can i do??
Getting an error.
Can you please help?

What error? Please show the error

Am I right in assuming you’re working with a custom version of Node-RED, either one already customised or one that you’re modifying yourself for your own needs.
Answering from mind, the post function you’re in looks like it’s an express route resolving function, which means NodeJS code. Your code starting with $.post is jquery, clientside. It might work on the editor side from say the configuration of a node, but can you verify first if the file you’re editing is serverside or clientside?

What error? We can’t help if we don’t know what error it is.

Did you watch the video?

Just put a http request node on the node-red editor.

Inject > http request > debug

I don't understand why you are inside the core node-red source code?

getting error like this. Guys i want to make a simple api call here in flows.js file...and tried like above.
Do you guys know any alternative for calling external api from js file?
Please guide.

@Steve-Mcl i dont want to call api by putting http.requst node to editor.
@afelix i am modifying myself for myown needs. Might be it is client side. Can you please guide me for a simple API call?

I literally have no idea what you are doing

That flow does nothing.

That error is client side jQuery & nothing to do with node red.

Please explain what you are trying to do.

@Steve-Mcl when we click on deploy we get in to flows.js file post i did comment that call and want to make my own api post call....Can you please guide me how can i make a simple api call here?
I want the exact syntax beacuse the one i used is not working........please.

Darshan, the function that is called when you press the deploy button lives in the runtime of node-red: this is server code, on nodejs. The code you have added to it uses jquery. Jquery is a framework for interacting with DOM structures in the browser, meaning it is clientside code.
If you want to do this, start by learning the difference between clientside and serverside, and learn some nodejs basics. Next, figure out a way to call http apis from nodejs.

The error you’re seeing is the call to the flows endpoint returning with a server error, status code 500 if I had to guess. You’re seeing that one in your browser because it is the response to a browser-made call, an XMLHttpRequest also known as XHR. You should also see the full error on the console/log where you run node-red.
The error you get “ReferenceError: is not defined” means that it has no clue what means so jquery is not available, which makes sense because you’re in the runtime. So it cannot make that call.

Are you trying to modify node-red functionality


build a flow that works like deploy button?

When you get this working, will it run inside a node-red flow or will it be a modified version of node-red?

@Steve-Mcl i am not modifying node-red flow...just making an api call

where would you like to make that call from? From when you click the deploy button, or by an action in your flow? First one means modifying node-red core itself, second means using nodes. That answer makes all the difference in the answer and approach

If you don't answer questions fully and clearly I can't help.

Surely you can see no one has a clue what you are trying to do?

If you want help, please be specific.