#Can we sent an array as payload while triggering through code ?
1 messages · Page 1 of 1 (latest)
Hi @loud falcon
Please share some sample code
like if we have an array of object
obj = {
name : "tom"
}[]
payload is a type of object which can take only key value pairs
This is a valid payload:-
payload: {
attachments: [
{
name: "",
mime: ""
}
]
}
but if the this array of object "attachments" has like 3 elements, how will we show each element in our own format in novu platform?
I think you can send, although attachments is reserved for internal purpose, but you can use other key
but how will I show the elements of this array in templates
You can do {{#each}} {{name}} {{/each}} or other array related syntax in handlebars
could you elaborate these formats a bit
@loud falcon
https://stackoverflow.com/questions/22696886/how-to-iterate-over-array-of-objects-in-handlebars
For example, for this case in the template
payload: {
array: [
{
name: 'gali',
score: 2,
},
{
name: 'david',
score: 5,
},
]
}
@elder rose Thank you, this was really helpful
thanks @supple gull @fervent escarp for the response, it worked
Hey guys, one doubt, in the custom code editor also the payload data is accessed with {{}}, right?