Function Node - Timing issue?

Hi Community

I fight with an interesting issue.

I would like to overwrite a simple value with the response of the previous node.
But get undefined from my overwrite after return


See image output of my debug. So it looks for me like a timeing issue? I have no glue whats run wrong.

The last console output tells me the code is normally fine, because then I have the value.

// Code here will run only once, no matter how many input items there are.
// More info and help:

let responseData = [];
const overwrite = ">>" + items[0].json.fullname + "<<";

console.log('with start it is empty: ' + overwrite);

responseData.push({json: {
// app: items[0].json,
data : [
     { key: "5", value: overwrite },
     { key: "6", value: "Data" },
     { key: "7", value: "Somewhere street 2" },
     { key: "8", value: "16222" },
     { key: "9", value: "Berlin" },
     { key: "10", value: "DE" },
     { key: "11", value: "0171 2827221" },
     { key: "2", value: "[email protected]" },
     { key: "3", value: "test" },
console.log('at the end --> Response is there.... -> ' + items[0].json.full_name);
return responseData;

Debug Output (browser)

Screenshot 2021-08-07 at 13.15.39

Any ideas?

Welcome to the community @Dave_H !

Are you sure that the previous node has a value for “fullname”? Can you please post a picture of the JSON data of the previous node.

1 Like

jap is 100% the previews see here.

and you see it also in the debug output - last console.log - is the same - in the image from my previous post.

Ah no, please from n8n, like this:
Screenshot from 2021-08-07 13-39-24

axo :slight_smile: sure. is filled with “Demo Data” like expected.

and here the response from the current function node:

Then you use the wrong name. It is “full_name” instead of “fullname”.

So you have to use: items[0].json.full_name

ahh I’m soooo stupid

thank you! no idea why I didn’t see it. Thank you for your quick response. I really like n8n! fantastic tool

No problem. The longer you look at something the harder it is sometimes to find the obvious things.

Glad to hear that you enjoy n8n. Have fun!

1 Like