I have a request that returns basically that
inside of each item theres is an object that has a "dataAbertura" field, a string
im trying to filter these results with that function, but its not working
msg.payload.value.data.filter(e => e.dataAbertura.startsWith('2021-03-08'))
can somebody tells me whats wrong with that and how could i do it?
ps: sorry for my bad english
Without seeing the data item or your full function it is almost impossible to say.
Do you assign the result of the filter function to msg.payload? Do you return the msg at the end of the function? Is dataAbertura a string? Does the data array contain objects & Is dataAbertura a parent property?
Colin
9 March 2021 18:03
3
Click on the array contents to expand one or more so we can see what is there.
E1cid
9 March 2021 18:14
4
From the info supplied the JSONata expression used in a change node to filter on dataAbertura
with dates containing the string '2021-03-08', would be
payload.value.data[$contains($.dataAbertura, "2021-03-08")]
But untested as you supplied no data
its an object like that one that contains a lot of fields, one of these fields its
and the complete function im using its
msg.payload.filter(e => e.dataAbertura.startsWith('2021-03-08'))
return msg;
with a debug node on the end
i cannot show u guys the entire object but it is a lot of fields like that "id" one
Try...
msg.payload = msg.payload.value.data.filter(e => e.dataAbertura.startsWith('2021-03-08'))
return msg;
1 Like
it works !!
im sorry if this question was silly guys im kinda lost in node red yet, thanks a lot for your help
system
Closed
23 March 2021 18:21
8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.