# Set and use Global OBJECT variable

**URL:** <https://discourse.nodered.org/t/set-and-use-global-object-variable/39944>\
**Category:** General\
**Created:** [28 January 2021 17:08 UTC](https://discourse.nodered.org/t/set-and-use-global-object-variable/39944 "2021-01-28T17:08:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gcronin66](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@gcronin66](https://discourse.nodered.org/u/gcronin66)\
**Post date:** [28 January 2021 17:08 UTC](https://discourse.nodered.org/t/set-and-use-global-object-variable/39944/1 "2021-01-28T17:08:06Z")

</div>

I'm working on a Web Audio project using an AudioContext() object.  
I would like to set this object as a global variable so I can create at start and use it within multiple flows.

I have a start-up node running this to set the Global:

var AUDIOcontextOBJECT = new AudioContext();  
global.set("AUDIOcontextOBJECT",AUDIOcontextOBJECT); //primary 'container' for all audio node objects

within a (template) node I try to reference the global with:

var AUDIOcontextOBJECT = global.get("AUDIOcontextOBJECT");

I receive the error: "global is not defined"

Any guidance is appreciated.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [28 January 2021 17:26 UTC](https://discourse.nodered.org/t/set-and-use-global-object-variable/39944/2 "2021-01-28T17:26:41Z")

</div>

Welcome to the forum @gcronin66.

If you look at the help text for the template node it shows you how to access global objects  
"It is possible to use a property from the flow context or global context. Just use {{flow.name}} or {{global.name}}, or for persistable store store use {{flow[store].name}} or {{global[store].name}}."

---

<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:** [28 January 2021 18:04 UTC](https://discourse.nodered.org/t/set-and-use-global-object-variable/39944/3 "2021-01-28T18:04:34Z")

</div>

Not possible.

AudioContext is a client side thing (runs in client browser). Global.set is a server side thing (runs in completely separate thread / 100% separate from your browser).

---

<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 March 2021 18:04 UTC](https://discourse.nodered.org/t/set-and-use-global-object-variable/39944/4 "2021-03-29T18:04:42Z")

</div>

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