# Updated to NR 3, now getting errors

**URL:** <https://discourse.nodered.org/t/updated-to-nr-3-now-getting-errors/91031>\
**Category:** General\
**Created:** [16 September 2024 20:11 UTC](https://discourse.nodered.org/t/updated-to-nr-3-now-getting-errors/91031 "2024-09-16T20:11:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![daxliniere](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daxliniere/32/42187_2.png) [@daxliniere](https://discourse.nodered.org/u/daxliniere)\
**Post date:** [16 September 2024 20:11 UTC](https://discourse.nodered.org/t/updated-to-nr-3-now-getting-errors/91031/1 "2024-09-16T20:11:29Z")

</div>

Hey gang,  
I recently updated to NR v3 and now one of my function nodes is throwing the error **"TypeError: msg.payload[0].filter is not a function"**

This is processing the output of the Unifi node which is generating a list of connected client devices. This code is filtering them and sending to separate outputs on the function node.

```auto
const lastSeenSeconds = 20;

let presenceCutoff = (Date.now() - (lastSeenSeconds * 1000)) / 1000; 
const people = {
    "presence/phone1": "redacted_MAC",
    "presence/phone2": "redacted_MAC",
    "presence/phone3": "redacted_MAC"
};

return Object.keys(people).map(function(topic) {
    let devices = msg.payload[0].filter(device => device.mac === people[topic]);
// let devices = msg.payload[0].filter(device => device.mac === people[topic]) && (device.last_seen > presenceCutoff);
    return {
        topic: topic,
        //retain: true,
        payload: devices.length > 0
    };
});

```

Anyone have any idea how to fix this?

Thanks in advance,  
Dax.

---

<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:** [16 September 2024 20:19 UTC](https://discourse.nodered.org/t/updated-to-nr-3-now-getting-errors/91031/2 "2024-09-16T20:19:28Z")

</div>

What is `msg.payload[0]` when the error is thrown

---

<div class="post-metadata">

**Author:** ![daxliniere](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daxliniere/32/42187_2.png) [@daxliniere](https://discourse.nodered.org/u/daxliniere)\
**Post date:** [16 September 2024 20:21 UTC](https://discourse.nodered.org/t/updated-to-nr-3-now-getting-errors/91031/3 "2024-09-16T20:21:37Z")

</div>

Hey @E1cid, honestly, I have no idea. The script was taken from an example about 4 years ago and has worked perfectly since then.

---

<div class="post-metadata">

**Author:** ![daxliniere](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daxliniere/32/42187_2.png) [@daxliniere](https://discourse.nodered.org/u/daxliniere)\
**Post date:** [16 September 2024 20:21 UTC](https://discourse.nodered.org/t/updated-to-nr-3-now-getting-errors/91031/4 "2024-09-16T20:21:58Z")

</div>

Oh, wait, are you asking to see an example payload? I can provide that if you like. 🙂

---

<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:** [16 September 2024 20:25 UTC](https://discourse.nodered.org/t/updated-to-nr-3-now-getting-errors/91031/5 "2024-09-16T20:25:14Z")

</div>

The use a debug node prior to the function, then you can see the value of msg.payload.  
or use `node.warn(typof msg.payload[0])` prior to the `let devices` line.

---

<div class="post-metadata">

**Author:** ![daxliniere](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/daxliniere/32/42187_2.png) [@daxliniere](https://discourse.nodered.org/u/daxliniere)\
**Post date:** [16 September 2024 20:25 UTC](https://discourse.nodered.org/t/updated-to-nr-3-now-getting-errors/91031/6 "2024-09-16T20:25:15Z")

</div>

This is now solved, though I'm still not sure what changed in order to break this. Either the way NR 3 treats data from the Unifi node or the format of the data outputted by the Unifi node.

Details are here: [Node-Red UniFi Presence.md · GitHub](https://gist.github.com/i8beef/ab6386f1bb8f25c154e51df9a465eb05?permalink_comment_id=3604982)

---

<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:** [30 September 2024 20:25 UTC](https://discourse.nodered.org/t/updated-to-nr-3-now-getting-errors/91031/7 "2024-09-30T20:25:59Z")

</div>

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