Again get data from a payload

i have again a problem to get data into a VAR.....
i copy the follow path in the debug area:
But i get a error in my function. "TYPE ERROR"
And the second problem is:
on next day the name of date change!
if it possible to say "get the second data in the result" ?
you can see all data in the screenshot:

[edited] you are right.

explanation see Extract data from object - #8 by TotallyInformation

But this structure (build by the source of this data) does not make much sense to me.
today and next day instead of the date would definitely make more sense.
I really don't know, if you can automatically insert the formatted date of the next date each time.

If you hover over the value you want 3 icons will appear to the right of the value.
If you press the leftmost icon, the path to the value will be copied to the clipboard, you can then paste this into your function.

Read this guide for more information on the structure of messages:

Ich sehe gerade deutsch geht bei dir auch.....
Meine Hoffnung war zu sagen:
Kopiere in die Variable immer den 2ten Wert auf dem Result

Hi, i have it done!
see my post above:
i copy the follow path in the debug area:

By that I meant that I used the copy path button

sorry my english is not so good...

He wrote:

"Always copy the 2nd value on the result into the variable"

Ich denke, das sollte auch klappen. Ich stelle Dein Beispiel bei mir mal nach. Moment ...

Mein Deutsch ist auch ziemlich gut :slight_smile:

thank you

hätte ich das vorher gewusst LOL

1 Like

the are needed because of the - in the name

You could calculate tomorrows date and use that to select the correct value

var test = {payload: 
                {"2023-08-25": 3342323423,
                 "2023-08-26": 33423111423

var test2 = { payload: "" };

test2.payload = test.payload.result["2023-08-26"];

return test2;

I built your object in a function node. If you complete it with a debug node, the result is the second value.
But I did not manage to get the value of the second object, nevertheless what it is called.
Somebody else have to jump in, I am afraid.

If you always want the second value of the object, you may have issues if the object is not created in same order, if it is this should work.

msg.payload = {
    result: {
        "2023-08-25": 3342323423,
        "2023-08-26": 33423111423
msg.payload = Object.values(msg.payload.result)[1];
return msg;

Or if the position are changing then you can as @smcgann99 suggests, you can calculate tomorrows date.

msg.payload = {
    result: {
        "2023-08-25": 3342323423,
        "2023-08-26": 33423111423
const date = new Date()
date.setDate(date.getDate() + 1);
let tomorrow = date.toISOString().split("T")[0];
msg.payload = msg.payload.result[tomorrow];
return msg;
1 Like

thank you for your answer, but it dont work with the first one. But this one that what i want....

var prognose = Object.values(msg.payload.result)[1];

return [
    { payload: prognose },

the result is:
TypeError: Cannot convert undefined or null to object

Not enough info to help you.
Please provide an example flow with the input data in a inject node.
[edit] I would think your input is not consistent and therefore the prognose could be undefined,. But really need more info to be sure.

I think your syntax does not work:

try another syntax:

var msg2 = { payload: "" };

msg2.payload =  Object.values(msg.payload.result)[1];

return msg2;

This is fine and should work, the [ ,] are not required unless you want to send to multiple outputs.

sorry thats to much information for me.
In the picture you can see what data is incomming into my function.
i need the data in line 2: 1724368

now i have the follow function but it not work:

var prognose = Object.values(msg.payload.result)[1];

return [
    { payload: prognose }

i attempt to export the flow an paste it here

it is not possible to paste it here. To much data

here is a link to get the flow.


To help to see what is going on, what does the function return if you use
var prognose = Object.values(msg.payload.result)