# Pulling specific data from a msg.payload object

**URL:** https://discourse.nodered.org/t/pulling-specific-data-from-a-msg-payload-object/48511
**Category:** General
**Created:** [17 July 2021 07:26 UTC](https://discourse.nodered.org/t/pulling-specific-data-from-a-msg-payload-object/48511 "2021-07-17T07:26:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Thewaver](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thewaver/32/11917_2.png) [@Thewaver](https://discourse.nodered.org/u/Thewaver)
#### Post date: [17 July 2021 07:26 UTC](https://discourse.nodered.org/t/pulling-specific-data-from-a-msg-payload-object/48511/1 "2021-07-17T07:26:49Z")

</div>

I am using the ewelink node and am stuck on trying to get a specific piece of data from the event listener node.  
The following is the debug output:  
object  
payload: object  
action: "update"  
deviceid: "xxxxxxxxx"  
apikey: "xxxxxxxxxxxxxxxxx"  
userAgent: "app"  
sequence: "1626505244322"  
params: object  
switch: "on"  
partnerApikey: "xxxxxxxxxxxxxxxxxx"  
tempRec: "10011229b3"  
\_msgid: "65dc165.fabe888"

I'm trying to access the switch variable (which can be either on or off) in the params object.  
I have copied the path to the params switch variable: 'payload.params.switch'.  
Maybe naively, in the function node I added:  
var onoff = payload.params.switch;  
return.msg;  
I now get an error message:  
ReferenceError: payload is not defined (line 1, col 13)  
Can anyone help in my error. Ive tried square and curly brackets and reading lots from google and node red but cant find an answer.

Also, trying to find a beginners book on node red but cant find any which I find quite unusal.  
Kind regards....

---

<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: [17 July 2021 07:30 UTC](https://discourse.nodered.org/t/pulling-specific-data-from-a-msg-payload-object/48511/2 "2021-07-17T07:30:40Z")

</div>

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

* * *

As a newbee, I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<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: [17 July 2021 07:48 UTC](https://discourse.nodered.org/t/pulling-specific-data-from-a-msg-payload-object/48511/3 "2021-07-17T07:48:39Z")

</div>

> [@Thewaver](#):
>
> var onoff = payload.params.switch;  
> return.msg;

When you copy the path , it does not copy the initial object e.g. msg  
try `msg.payload.params.switch`

---

<div class="post-metadata">

### Author: ![Thewaver](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thewaver/32/11917_2.png) [@Thewaver](https://discourse.nodered.org/u/Thewaver)
#### Post date: [17 July 2021 07:55 UTC](https://discourse.nodered.org/t/pulling-specific-data-from-a-msg-payload-object/48511/4 "2021-07-17T07:55:31Z")

</div>

Hi, thanks for you reply. I have followed, read and watched all what you have suggested but no where can I find info on how to pull a specific data item from the object. Cheers....

---

<div class="post-metadata">

### Author: ![Thewaver](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thewaver/32/11917_2.png) [@Thewaver](https://discourse.nodered.org/u/Thewaver)
#### Post date: [17 July 2021 07:57 UTC](https://discourse.nodered.org/t/pulling-specific-data-from-a-msg-payload-object/48511/5 "2021-07-17T07:57:51Z")

</div>

Hi, thanks for your reply. That did the trick. Its always something that is so simple which I can never find. I desperately need an idiots guide to node-red....

---

<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: [31 July 2021 07:57 UTC](https://discourse.nodered.org/t/pulling-specific-data-from-a-msg-payload-object/48511/6 "2021-07-31T07:57:59Z")

</div>

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