After the update, the code node stopped working

Hello I need help.

I had a simple code that checked if a word was in a list.

I used it a long time ago on the n8n, but when I needed to use it again it didn’t work.

Can someone help me.

The code is:

const wordInput = “{{ $json.body.message[0].message.conversation }}”; // Replace “example” with the word you want as input

const wordlist = [“example”, “other”, “word”, “list”]; // Define your word list

function checkWordInList(word, list) {
for (const wordList of list) {
if (wordList === word) {
return 2; // If the word is in the list, returns 2
}
}
return 1; // If the word is not in the list, returns 1
}

const result = checkWordInList(wordInput, listOfWords);

return {
json: {
result: result
}
};

Hi @Arte :wave: It’s hard to know without a sample JSON of what your input structure looks like, but we have a doc explaining how to access the output of other nodes now: Output of other nodes | n8n Docs

You’d need something like $('Node Name').item.json... instead :bowing_man: If you’re still stuck, feel free to share some example JSON so we can help you a little further :+1:

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