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

**URL:** <https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568>\
**Category:** Core Development\
**Created:** [13 May 2020 05:37 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568 "2020-05-13T05:37:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhpatel177](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dhpatel177/32/39248_2.png) [@dhpatel177](https://discourse.nodered.org/u/dhpatel177)\
**Post date:** [13 May 2020 05:37 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/1 "2020-05-13T05:37:31Z")

</div>

Hello,

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

Thanks

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [13 May 2020 05:41 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/2 "2020-05-13T05:41:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dhpatel177](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dhpatel177/32/39248_2.png) [@dhpatel177](https://discourse.nodered.org/u/dhpatel177)\
**Post date:** [13 May 2020 05:46 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/3 "2020-05-13T05:46:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [13 May 2020 05:52 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/4 "2020-05-13T05:52:52Z")

</div>

> 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](https://cookbook.nodered.org) "HTTP requests"

---

<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:** [13 May 2020 06:51 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/5 "2020-05-13T06:51:50Z")

</div>

Is this the same problem as this [thread](https://discourse.nodered.org/t/how-to-download-flows-json-using-api/26507/13)

---

<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:** [13 May 2020 06:51 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/6 "2020-05-13T06:51:59Z")

</div>



---

<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:** [13 May 2020 07:04 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/7 "2020-05-13T07:04:24Z")

</div>



---

<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:** [13 May 2020 07:09 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/8 "2020-05-13T07:09:34Z")

</div>

Watch this [http://www.steves-internet-guide.com/node-red-http-request-node-beginners/](http://www.steves-internet-guide.com/node-red-http-request-node-beginners/)

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.

---

<div class="post-metadata">

**Author:** ![dhpatel177](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dhpatel177/32/39248_2.png) [@dhpatel177](https://discourse.nodered.org/u/dhpatel177)\
**Post date:** [13 May 2020 08:00 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/9 "2020-05-13T08:00:54Z")

</div>

![Capture](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/35f14fe8d0cc7d36ad5d6a6b48751d6af6ea1034.png)

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

---

<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:** [13 May 2020 08:05 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/10 "2020-05-13T08:05:20Z")

</div>

What error? Please show the error

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [13 May 2020 08:07 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/11 "2020-05-13T08:07:21Z")

</div>

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?

> [@dhpatel177](#):
>
> Getting an error.

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

---

<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:** [13 May 2020 08:07 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/12 "2020-05-13T08:07:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dhpatel177](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dhpatel177/32/39248_2.png) [@dhpatel177](https://discourse.nodered.org/u/dhpatel177)\
**Post date:** [13 May 2020 08:13 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/13 "2020-05-13T08:13:58Z")

</div>

![Capture](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/4/3475540e3165c09946a02057f1170767cc39c697.png)

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?

---

<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:** [13 May 2020 08:18 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/14 "2020-05-13T08:18:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dhpatel177](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dhpatel177/32/39248_2.png) [@dhpatel177](https://discourse.nodered.org/u/dhpatel177)\
**Post date:** [13 May 2020 08:23 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/15 "2020-05-13T08:23:31Z")

</div>

@Steve-Mcl when we click on deploy we get in to flows.js file post call...so 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.

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [13 May 2020 08:26 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/16 "2020-05-13T08:26:57Z")

</div>

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.

---

<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:** [13 May 2020 08:28 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/17 "2020-05-13T08:28:44Z")

</div>

Are you trying to modify node-red functionality

or

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?

---

<div class="post-metadata">

**Author:** ![dhpatel177](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dhpatel177/32/39248_2.png) [@dhpatel177](https://discourse.nodered.org/u/dhpatel177)\
**Post date:** [13 May 2020 08:32 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/18 "2020-05-13T08:32:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [13 May 2020 08:35 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/19 "2020-05-13T08:35:02Z")

</div>

**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

---

<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:** [13 May 2020 08:35 UTC](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568/20 "2020-05-13T08:35:23Z")

</div>

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.

[Next page](https://discourse.nodered.org/t/how-to-modify-node-red-deploy-operation-to-save-flow-to-database/26568.md?page=2)
