# Payload to javascript array

**URL:** <https://discourse.nodered.org/t/payload-to-javascript-array/27306>\
**Category:** Dashboard\
**Created:** [26 May 2020 10:45 UTC](https://discourse.nodered.org/t/payload-to-javascript-array/27306 "2020-05-26T10:45:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![josekavunkal](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/josekavunkal/32/18505_2.png) [@josekavunkal](https://discourse.nodered.org/u/josekavunkal)\
**Post date:** [26 May 2020 10:45 UTC](https://discourse.nodered.org/t/payload-to-javascript-array/27306/1 "2020-05-26T10:45:55Z")

</div>

I have an array in template node as below.

var myContacts = [  
{"rowid":1, "name": "Parvez Ansari", "email": "[ansariparvez@gmai.com](mailto:ansariparvez@gmai.com)", "mobile":"9998979695" },  
{"rowid":2, "name": "Tayyeb Shaikh", "email": "[tshaikh1981@gmai.com](mailto:tshaikh1981@gmai.com)", "mobile":"9091929394" },  
{"rowid":3, "name": "Ashfaque Shaikh", "email": "[ashly786@gmai.com](mailto:ashly786@gmai.com)", "mobile":"8081828384" }  
];

This need to be replaced using array in payload .

I have a function in template node which will be called in onload event.  
Can I iterate the payload and push it to the javascript array myContacts ?  
The field in the row is not fixed ,it is as per the DB outtput.  
Basically I need to copy everything in payload and create a javascript array .  
Can I use mustache?.Please help.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 May 2020 20:57 UTC](https://discourse.nodered.org/t/payload-to-javascript-array/27306/2 "2020-05-28T20:57:08Z")

</div>

You mat need to use the $watch feature of Angular in your tempalte code, this is the part that will watch for new incoming data and let you process it.

I have a few examples on my blog at [https://it.knightnet.org.uk](https://it.knightnet.org.uk) but there are plenty of examples elsewhere too.

---

<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:** [27 June 2020 20:57 UTC](https://discourse.nodered.org/t/payload-to-javascript-array/27306/3 "2020-06-27T20:57:14Z")

</div>

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