# Get Data to Var... but nothing work

**URL:** <https://discourse.nodered.org/t/get-data-to-var-but-nothing-work/77571>\
**Category:** General\
**Created:** [14 April 2023 17:02 UTC](https://discourse.nodered.org/t/get-data-to-var-but-nothing-work/77571 "2023-04-14T17:02:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![einfach112](https://avatars.discourse-cdn.com/v4/letter/e/3da27b/32.png) [@einfach112](https://discourse.nodered.org/u/einfach112)\
**Post date:** [14 April 2023 17:02 UTC](https://discourse.nodered.org/t/get-data-to-var-but-nothing-work/77571/1 "2023-04-14T17:02:02Z")

</div>

hi!  
i have a catch node.  
on this node is a debug node.  
the return on the debug node is:

```auto
14.4.2023, 19:00:30node: debug 43
msg : Object
object
error: object
message: "no JSON"
source: object
value: undefined
_error: "Error: no JSON"
_msgid: "f8b6616adb8c44bc"

```

on the same catch node is a Function node. I want to read the error with the follow script:

```auto
var erroreins = msg.payload.error.message;
if (erroreins == "no JSON") {
    return [
        { payload: 'restart' },

    ]
}

```

but it do not work....  
I copy the path with the "Copy Path" function.  
If i get a Error the Function do not work.....  
Why?

here is a link to the debug message....

> **[debug hosted at ImgBB](https://ibb.co/fFMFTdv)**
>
> Image debug hosted in ImgBB

---

<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:** [14 April 2023 17:22 UTC](https://discourse.nodered.org/t/get-data-to-var-but-nothing-work/77571/2 "2023-04-14T17:22:44Z")

</div>

I see no mention of payload in the debug output, hmm? I do see `msg``error` and `message`.  
Have you tried using the copy path button that appears when you hover the cursor over message property name in the debug panel?

 ![image16](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/f/9f7691ba3bc3f30a20cb1cef819bfdcf93a3312c.jpeg)

---

<div class="post-metadata">

**Author:** ![einfach112](https://avatars.discourse-cdn.com/v4/letter/e/3da27b/32.png) [@einfach112](https://discourse.nodered.org/u/einfach112)\
**Post date:** [14 April 2023 17:33 UTC](https://discourse.nodered.org/t/get-data-to-var-but-nothing-work/77571/3 "2023-04-14T17:33:37Z")

</div>

sorry ... i can't reproduce it now... i need some time to reproduce it....  
i hope i need one of two hours (but i have use the copy path button behind the message)

---

<div class="post-metadata">

**Author:** ![einfach112](https://avatars.discourse-cdn.com/v4/letter/e/3da27b/32.png) [@einfach112](https://discourse.nodered.org/u/einfach112)\
**Post date:** [14 April 2023 17:44 UTC](https://discourse.nodered.org/t/get-data-to-var-but-nothing-work/77571/4 "2023-04-14T17:44:16Z")

</div>

ok here the next picture with copy path.....

> **[zweiter hosted at ImgBB](https://ibb.co/bNv58T5)**
>
> Image zweiter hosted in ImgBB

After click i got the follow:  
error.message  
i think everytime is it a msg.payload? so i think its right:  
msg.payload.error.message  
???

---

<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:** [14 April 2023 17:49 UTC](https://discourse.nodered.org/t/get-data-to-var-but-nothing-work/77571/5 "2023-04-14T17:49:18Z")

</div>

It is always msg when it enters or outputs a function node, after that you can use any property name you wish. Using copy path you should always add msg when using it in a function node.

As this is an error it is sent in msg.error, as payload is probably carrying other data.

---

<div class="post-metadata">

**Author:** ![einfach112](https://avatars.discourse-cdn.com/v4/letter/e/3da27b/32.png) [@einfach112](https://discourse.nodered.org/u/einfach112)\
**Post date:** [18 April 2023 13:02 UTC](https://discourse.nodered.org/t/get-data-to-var-but-nothing-work/77571/6 "2023-04-18T13:02:04Z")

</div>

THANK YOU,  
! NOW IT RUN!  
Thank you very much!

---

<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:** [2 May 2023 13:02 UTC](https://discourse.nodered.org/t/get-data-to-var-but-nothing-work/77571/7 "2023-05-02T13:02:34Z")

</div>

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