# Get All Env In Subflow

**URL:** <https://discourse.nodered.org/t/get-all-env-in-subflow/21392>\
**Category:** General\
**Created:** [7 February 2020 11:18 UTC](https://discourse.nodered.org/t/get-all-env-in-subflow/21392 "2020-02-07T11:18:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soloam](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/soloam/32/9834_2.png) [@Soloam](https://discourse.nodered.org/u/Soloam)\
**Post date:** [7 February 2020 11:18 UTC](https://discourse.nodered.org/t/get-all-env-in-subflow/21392/1 "2020-02-07T11:18:15Z")

</div>

Hello, I would like to know if it's possible to list all the env that are declared on a subflow! I would like to simplify my code from mapping the env to specific variables, and I would like them to be dynamic! Something like:

```auto
for(var e in env)
    msg[e] = env.get(e);

return msg;

```

This also would be useful in the global

Thank you

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [7 February 2020 11:20 UTC](https://discourse.nodered.org/t/get-all-env-in-subflow/21392/2 "2020-02-07T11:20:50Z")

</div>

Hi @Soloam

it is not possible to list the env vars set on a subflow. We only provide `env.get()` as a way to get the value of a known env var.

> [@Soloam](#):
>
> I would like them to be dynamic!

Env vars cannot be dynamic. Their main use is to allow per-subflow customisation of nodes within the subflow. Nodes cannot dynamically change their settings.

---

<div class="post-metadata">

**Author:** ![Soloam](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/soloam/32/9834_2.png) [@Soloam](https://discourse.nodered.org/u/Soloam)\
**Post date:** [7 February 2020 11:23 UTC](https://discourse.nodered.org/t/get-all-env-in-subflow/21392/3 "2020-02-07T11:23:54Z")

</div>

Thank you @knolleary put that in your "To Think one day if I have the time. Probably not! Not!" list 🙂 . That would be a got thing, a way to retrieve all the env (and if possible, global, flow) variables.

Thank you

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [7 February 2020 11:27 UTC](https://discourse.nodered.org/t/get-all-env-in-subflow/21392/4 "2020-02-07T11:27:58Z")

</div>

> [@Soloam](#):
>
> and if possible, global, flow)

You can already use `flow.keys()` and `global.keys()`. We don't have the equivalent for `env` - there are good reasons for not allowing a flow to get all the env vars - as they will typically be used to provide passwords or other secure details. Allowing a flow to iterate over them and report their value would be a potential security issue. Same reason we don't expose `process.env` in the Function node by default.

---

<div class="post-metadata">

**Author:** ![Soloam](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/soloam/32/9834_2.png) [@Soloam](https://discourse.nodered.org/u/Soloam)\
**Post date:** [7 February 2020 11:36 UTC](https://discourse.nodered.org/t/get-all-env-in-subflow/21392/5 "2020-02-07T11:36:53Z")

</div>

I understand @knolleary , in the env the keys() should be more restrict. It should only return in nodered subflow the env that are declared in that subflow. The subflow is under my control, so if I put a password in the subflow interface it would not be exposing any sensitive data, because I put it there, and I know it. Basically I'm getting data that I put there! Not data that someone put there, the subflow is written by me (or loaded by me) and unique to my nodered instance. From that point of view, the global.keys() and flow.keys() are also very sensitive, they also can store passwords (to reuse in multiple flows for example, we can't add a costume configure node to that).

Thank You

---

<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:** [7 April 2020 11:36 UTC](https://discourse.nodered.org/t/get-all-env-in-subflow/21392/6 "2020-04-07T11:36:53Z")

</div>

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