# Add additional logic on POST /flows request

**URL:** <https://discourse.nodered.org/t/add-additional-logic-on-post-flows-request/71460>\
**Category:** General\
**Created:** [29 November 2022 15:06 UTC](https://discourse.nodered.org/t/add-additional-logic-on-post-flows-request/71460 "2022-11-29T15:06:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dannyhuly](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dannyhuly/32/71604_2.png) [@dannyhuly](https://discourse.nodered.org/u/dannyhuly)\
**Post date:** [29 November 2022 15:06 UTC](https://discourse.nodered.org/t/add-additional-logic-on-post-flows-request/71460/1 "2022-11-29T15:06:10Z")

</div>

Hi,

I would like to intercept the **POST /flows** API request (at runtime) and add additional logic before its sending a respond to the editor.  
After looking at the docs I wasn't able to find hooks or other options to active this behavior.

Currently the only way I was able to detect the request is by accessing the RED.server (NodeRed node http server) object like this:

```nohighlight
RED.server.on("request", (req, res) => { ... })

```

But I'm unable to make it wait for my logic to finish.

Any Ideas will be welcome.  
Thanks.

---

<div class="post-metadata">

**Author:** ![dannyhuly](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dannyhuly/32/71604_2.png) [@dannyhuly](https://discourse.nodered.org/u/dannyhuly)\
**Post date:** [30 November 2022 07:22 UTC](https://discourse.nodered.org/t/add-additional-logic-on-post-flows-request/71460/2 "2022-11-30T07:22:10Z")

</div>

I Found a way to intercept the **setFlow** action although very hacky

```nohighlight
import RED from 'node-red';

...

const setFlowOrg: Function = (RED as any).runtime.flows.setFlows;
const flowThis: any = (RED as any).runtime.flows;

(RED as any).runtime.flows.setFlows = async (...data: any[]) => {
  console.log("before.setFlows");
  const res = await setFlowOrg.apply(flowThis, data);
  console.log("after.setFlows");
  return res; 
}

```

---

<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 January 2023 07:23 UTC](https://discourse.nodered.org/t/add-additional-logic-on-post-flows-request/71460/3 "2023-01-29T07:23:04Z")

</div>

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