Hello, I need to extract 2 characters from a payload (string) using substr(x,y) in a function node and it doesn't work. ex : var temperature = payload.substr(2,4). The function doesn't exist. Should I install a package or use an other function ? Do you have a tip? Or at least how to extract one character from a string?
I have Node red V1.3.2.
Thanks for the answer.
Dont know if you just miss typed but:
should be:
var temperature = msg.payload.substr(2,4);
as only using payload will give you not a function as you need to qualify the whole object path of a msg object property not just the key itself.
Johannes
Also if you just want 2 characters it should be msg.payload.substr(2,2)
Thanks both of you for the answer it's clear, it works.
Fabrice
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.