# A TO and FROM payload issue

**URL:** <https://discourse.nodered.org/t/a-to-and-from-payload-issue/88205>\
**Category:** General\
**Created:** [23 May 2024 16:33 UTC](https://discourse.nodered.org/t/a-to-and-from-payload-issue/88205 "2024-05-23T16:33:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Linhey](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/linhey/32/73679_2.png) [@Linhey](https://discourse.nodered.org/u/Linhey)\
**Post date:** [23 May 2024 16:33 UTC](https://discourse.nodered.org/t/a-to-and-from-payload-issue/88205/1 "2024-05-23T16:33:07Z")

</div>

I thought I was going mad, but I have stumbled upon a problem from the  
node-red-contrib-sun-position, when using the Moon Node.

The payload output includes the following:-

```auto
illumination: object
fraction: 0.9986036727069301
phase: object
   from: 0.466136806691289
   to: 0.533863193308711
   id: "fullMoon"
   emoji: "🌝"
   code: ":full_moon_with_face:"
   name: "Full Moon"
   weight: 1
   css: "wi-moon-full"
   phaseValue: 0.48810279726926675
   angle: -3.085705283802389

```

So the snag is this.  
I want to capture the **from** and **to** data and add this to a function, but I can't, because  
msg.payload.illumination.phase\*\*.from\*\* is an issue and so is  
msg.payload.illumination.phase\*\*.to\*\* an issue, how do I get round this problem?

---

<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:** [23 May 2024 16:44 UTC](https://discourse.nodered.org/t/a-to-and-from-payload-issue/88205/2 "2024-05-23T16:44:52Z")

</div>

I'm not quite clear on what the issue is.

Is `phase` a property beneath the `illumination` property, or alongside it? It isn't entirely clear from what you have pasted as the indenting may be misleading.

Can you share a screenshot of the object from the Debug sidebar so we can see its true structure? Alternatively, click the 'copy value' button in the debug sidebar alongside the message so we can see the full structure?

---

<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:** [23 May 2024 16:46 UTC](https://discourse.nodered.org/t/a-to-and-from-payload-issue/88205/3 "2024-05-23T16:46:04Z")

</div>

That is because the data is not in payload from the looks of what you have posted, it looks like it is in `msg.illumination.phase.from`

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path/value for 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)

---

<div class="post-metadata">

**Author:** ![Linhey](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/linhey/32/73679_2.png) [@Linhey](https://discourse.nodered.org/u/Linhey)\
**Post date:** [24 May 2024 08:54 UTC](https://discourse.nodered.org/t/a-to-and-from-payload-issue/88205/4 "2024-05-24T08:54:52Z")

</div>

Thanks for your replies, my fault I didn't explain the issue properly.  
I have been using Node-Red for a couple of years now, so I know how to obtain the path and data of any messages and have built some fairly complex projects.

What was puzzling me was that if I simply **write** the following in a function node I got an error, **without running it.**

var x = msg.payload.illumination.phase.from  
var y = msg.payload.illumination.phase.to

So it really doesn't matter what the payload is as I never had the opportunity to run it.

I asked the question as I couldn't see any particular reason why this should be a problem. Since then I have rebooted Node-Red and the issue has gone away and I can now write this into the function. It seems Node-Red itself had some issue and perhaps I should have rebooted it in the first place before asking the question.

Just for reference the Moon Node has the following output of the _complete msg object_, showing the only msg outside of the payload is the lat, lon and topic.

```auto
{"_msgid":"a066365ad9562745","lat":51.509865,"lon":-0.118092,"payload":{"ts":1716539734000,"lastUpdate":"2024-05-24T08:35:34.000Z","lastUpdateStr":"2024-05-24T09:35:34","latitude":51.509865,"longitude":-0.118092,"angleType":"deg","azimuth":275.8934816671064,"altitude":-39.24643914147571,"altitudeDegrees":-39.24643914147571,"azimuthDegrees":275.8934816671064,"altitudeRadians":-0.6849795827023278,"azimuthRadians":4.815249639881621,"distance":387839.64345437713,"parallacticAngle":43.92348800383688,"illumination":{"fraction":0.9927357733030052,"phase":{"from":0.466136806691289,"to":0.533863193308711,"id":"fullMoon","emoji":"🌝","code":":full_moon_with_face:","name":"Full Moon","weight":1,"css":"wi-moon-full"},"phaseValue":0.5271626432772403,"angle":2.1990735294888193,"next":{"value":1717076698261.5,"date":"2024-05-30T13:44:58.261Z","type":"thirdQuarter","newMoon":{"value":1717714558956,"date":"2024-06-06T22:55:58.956Z"},"fullMoon":{"value":1718990280345,"date":"2024-06-21T17:18:00.345Z"},"firstQuarter":{"value":1718352419650.5,"date":"2024-06-14T08:06:59.650Z"},"thirdQuarter":{"value":1717076698261.5,"date":"2024-05-30T13:44:58.261Z"}}},"zenithAngle":82.07414407481025,"times":{"rise":"2024-05-24T21:45:16.450Z","set":"2024-05-24T03:49:56.069Z","alwaysUp":false,"alwaysDown":false,"highest":"2024-05-24T12:47:36.259Z"},"positionAtRise":{"azimuth":2.4110902793848616,"altitude":0.0037763630712496594,"azimuthDegrees":138.1452970337711,"altitudeDegrees":0.21636966589166687,"distance":385234.2249828217,"parallacticAngle":-0.48894960950229566,"parallacticAngleDegrees":-28.014749019051234},"positionAtSet":{"azimuth":3.928591365849633,"altitude":0.0030079180325627885,"azimuthDegrees":225.0917046947195,"altitudeDegrees":0.1723410083871419,"distance":388773.20643887366,"parallacticAngle":0.5142043676908113,"parallacticAngleDegrees":29.461740075876637},"highestPosition":{"azimuth":0.06278820271705365,"altitude":-1.1374260162897294,"azimuthDegrees":3.597499018899023,"altitudeDegrees":-65.16971024177992,"distance":387010.99659302,"parallacticAngle":-0.043920524934587556,"parallacticAngleDegrees":-2.516460712750963},"altitudePercent":60.22190216263237,"isUp":false,"pos":[],"posChanged":false},"topic":"moon"}

```

---

<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:** [24 May 2024 08:55 UTC](https://discourse.nodered.org/t/a-to-and-from-payload-issue/88205/5 "2024-05-24T08:55:36Z")

</div>

> [@Linhey](#):
>
> What was puzzling me was that if I simply **write** the following in a function node I got an error, **without running it.**

Any details on _what_ error you get?

---

<div class="post-metadata">

**Author:** ![Linhey](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/linhey/32/73679_2.png) [@Linhey](https://discourse.nodered.org/u/Linhey)\
**Post date:** [24 May 2024 08:57 UTC](https://discourse.nodered.org/t/a-to-and-from-payload-issue/88205/6 "2024-05-24T08:57:29Z")

</div>

Just the Node error when you write garbage into a function and it stops you deploying

---

<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:** [24 May 2024 09:07 UTC](https://discourse.nodered.org/t/a-to-and-from-payload-issue/88205/7 "2024-05-24T09:07:22Z")

</div>

> [@Linhey](#):
>
> What was puzzling me was that if I simply **write** the following in a function node I got an error, **without running it.**
> 
> var x = msg.payload.illumination.phase.from  
> var y = msg.payload.illumination.phase.to

I get no such error

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/e/ce4f0e7e698ce6887dd21bacbe40f434eeae57ff.png)

what version of Node-RED are you using?

Show us a screenshot please.

---

<div class="post-metadata">

**Author:** ![Linhey](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/linhey/32/73679_2.png) [@Linhey](https://discourse.nodered.org/u/Linhey)\
**Post date:** [24 May 2024 09:09 UTC](https://discourse.nodered.org/t/a-to-and-from-payload-issue/88205/8 "2024-05-24T09:09:04Z")

</div>

As already replied - after rebooting Node-Red, I no longer have an issue.

Node-Red v 3.1.9

---

<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:** [7 June 2024 09:09 UTC](https://discourse.nodered.org/t/a-to-and-from-payload-issue/88205/9 "2024-06-07T09:09:08Z")

</div>

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