# Node context not a function?

**URL:** https://discourse.nodered.org/t/node-context-not-a-function/91141
**Category:** General
**Created:** [20 September 2024 13:41 UTC](https://discourse.nodered.org/t/node-context-not-a-function/91141 "2024-09-20T13:41:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)
#### Post date: [20 September 2024 13:41 UTC](https://discourse.nodered.org/t/node-context-not-a-function/91141/1 "2024-09-20T13:41:39Z")

</div>

Have used context successfully for both global and flow. According to documentation, there is also node context. But can't get this to work and don't find any examples.

For example:

node.get("key");  
node.set("key", msg.payload);

What am I missing?

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [20 September 2024 13:46 UTC](https://discourse.nodered.org/t/node-context-not-a-function/91141/2 "2024-09-20T13:46:35Z")

</div>

That would be  
context.set(path,value,store)  
context.get(path,store)  
[https://nodered.org/docs/user-guide/writing-functions#context](https://nodered.org/docs/user-guide/writing-functions#context)

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [20 September 2024 13:59 UTC](https://discourse.nodered.org/t/node-context-not-a-function/91141/3 "2024-09-20T13:59:37Z")

</div>

A simple example...

```auto
[{"id":"327c773e3f240405","type":"inject","z":"be4568a984cb4685","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":290,"y":2080,"wires":[["db2adbcefcbaa0d1"]]},{"id":"db2adbcefcbaa0d1","type":"function","z":"be4568a984cb4685","name":"function 7","func":"let storedCounter = context.get('count') || 0\nlet currentCounter = storedCounter + 1\ncontext.set('count', currentCounter)\nmsg.payload = currentCounter\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":2080,"wires":[["61ef5ffd74b3869d"]]},{"id":"61ef5ffd74b3869d","type":"debug","z":"be4568a984cb4685","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":2080,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)
#### Post date: [20 September 2024 14:24 UTC](https://discourse.nodered.org/t/node-context-not-a-function/91141/4 "2024-09-20T14:24:25Z")

</div>

Thanks, somehow missed the API section (thought it was Rest api without looking).

---

<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: [4 October 2024 14:24 UTC](https://discourse.nodered.org/t/node-context-not-a-function/91141/5 "2024-10-04T14:24:31Z")

</div>

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