i'm kinda new both to node-red and java script and i was trying to log data on a file and then read back a single line from an arbitrary position.
For the first part, i simply used the node-red File node, appending to a file the new data and enabling the "Add newline" option.
For the reading part, after some researching i came to the conclusion that perhaps i could use the node.js module called "nthline". So i installed it globally through npm and then went to node-red settings.js to add the line
nthline:require('nthline') to the functionGlobalContext section.
Then in the function node of my flow i added:
var getline = global.get('nthline');
msg.payload = getline(5, '/home/test/testfile.txt');
but in the debug window, the message the function node outputs has empty payload.
What did i do wrong? Is there maybe a betetr way to read a single specific line from a file?
Thanks in advance