# Add payload to an array

**URL:** <https://discourse.nodered.org/t/add-payload-to-an-array/47652>\
**Category:** General\
**Created:** [25 June 2021 11:41 UTC](https://discourse.nodered.org/t/add-payload-to-an-array/47652 "2021-06-25T11:41:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![uselucoustic](https://avatars.discourse-cdn.com/v4/letter/u/cdc98d/32.png) [@uselucoustic](https://discourse.nodered.org/u/uselucoustic)\
**Post date:** [25 June 2021 11:41 UTC](https://discourse.nodered.org/t/add-payload-to-an-array/47652/1 "2021-06-25T11:41:50Z")

</div>

I have issue getting more quotation every time new new payload pushed to an array.  
The flow is working fine without connecting to csv node. Please advise

 ![Flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/5/b51ff9c79ae4f638a7d4fa4520819d94219f994b.jpeg)  
 ![Function](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/7/670bcec323ef62440e586e548e3c9e2de64248dd.jpeg)  
[flows (12).json](https://discourse.nodered.org/uploads/short-url/kkZw2pcmaY07ZspSKFVdsdDUuel.json) (3.4 KB)  
.

---

<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:** [25 June 2021 11:47 UTC](https://discourse.nodered.org/t/add-payload-to-an-array/47652/2 "2021-06-25T11:47:30Z")

</div>

change your function to ...

```auto
var array = flow.get('arraytest') || [];
array.push(msg.payload);
flow.set("arraytest", array);
msg.payload = [...array];
return msg;

```

---

<div class="post-metadata">

**Author:** ![uselucoustic](https://avatars.discourse-cdn.com/v4/letter/u/cdc98d/32.png) [@uselucoustic](https://discourse.nodered.org/u/uselucoustic)\
**Post date:** [26 June 2021 05:43 UTC](https://discourse.nodered.org/t/add-payload-to-an-array/47652/3 "2021-06-26T05:43:47Z")

</div>

it works. What is the three doted line functioning to?

---

<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:** [26 June 2021 07:04 UTC](https://discourse.nodered.org/t/add-payload-to-an-array/47652/4 "2021-06-26T07:04:35Z")

</div>

It is called [spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)

---

<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:** [17 August 2021 11:51 UTC](https://discourse.nodered.org/t/add-payload-to-an-array/47652/5 "2021-08-17T11:51:09Z")

</div>

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