# Is the documention right on node context?

**URL:** <https://discourse.nodered.org/t/is-the-documention-right-on-node-context/1463>\
**Category:** General\
**Created:** [9 July 2018 12:54 UTC](https://discourse.nodered.org/t/is-the-documention-right-on-node-context/1463 "2018-07-09T12:54:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [9 July 2018 12:54 UTC](https://discourse.nodered.org/t/is-the-documention-right-on-node-context/1463/1 "2018-07-09T12:54:01Z")

</div>

I'm writing a function node that needs to use the node context but on [https://nodered.org/docs/creating-nodes/context](https://nodered.org/docs/creating-nodes/context)  
it shows

```
// Access the node's context object
var context = this.context();

var count = context.get('count') || 0;
count += 1;
context.set('count',count);
//added by me to return the count
msg.payload = context.get('count');
return msg

```

But unless I comment out the 1st line I get an error when I use this example  
#Confused ☹

---

<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:** [9 July 2018 12:57 UTC](https://discourse.nodered.org/t/is-the-documention-right-on-node-context/1463/2 "2018-07-09T12:57:55Z")

</div>

You are looking at the docs on creating custom nodes. In that case, that first line is required.

The documentation for using Context in the Function node is [here](https://nodered.org/docs/writing-functions#storing-data) and doesn't require that first line as `context` is already defined.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [9 July 2018 13:03 UTC](https://discourse.nodered.org/t/is-the-documention-right-on-node-context/1463/3 "2018-07-09T13:03:39Z")

</div>

That explains things! 🙂

I just clicked on 1st result instead of the 2nd one

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/241fb6d3248cf1bef02070ec9c8289fb026c1437.png)
