# Function multiple output

**URL:** <https://discourse.nodered.org/t/function-multiple-output/45789>\
**Category:** General\
**Created:** [17 May 2021 14:19 UTC](https://discourse.nodered.org/t/function-multiple-output/45789 "2021-05-17T14:19:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![radjesth](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@radjesth](https://discourse.nodered.org/u/radjesth)\
**Post date:** [17 May 2021 14:19 UTC](https://discourse.nodered.org/t/function-multiple-output/45789/1 "2021-05-17T14:19:29Z")

</div>

Hello experts

I have the following function

var x = msg.payload  
msg2.payload = x,  
msg2.topic="auth"  
msg1.notify="auth"  
return [msg1 , msg2];

I have 2 outputs, but I am getting an error for msg2  
"ReferenceError: msg2 is not defined (line 2, col 1)"  
I have followed the steps of lessons, but can not get it to work.  
What am I missing

---

<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 May 2021 14:26 UTC](https://discourse.nodered.org/t/function-multiple-output/45789/2 "2021-05-17T14:26:32Z")

</div>

> [@radjesth](#):
>
> What am I missing

Declaration.

```auto
var msg1 = {};
var msg2 = {};
//...
//Your code
//...
return [msg1 , msg2];

```

---

<div class="post-metadata">

**Author:** ![radjesth](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@radjesth](https://discourse.nodered.org/u/radjesth)\
**Post date:** [17 May 2021 14:41 UTC](https://discourse.nodered.org/t/function-multiple-output/45789/3 "2021-05-17T14:41:04Z")

</div>

Thanks Steve,

---

<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:** [16 July 2021 14:41 UTC](https://discourse.nodered.org/t/function-multiple-output/45789/4 "2021-07-16T14:41:39Z")

</div>

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