Le-Ze
1
Hi. What am I doing wrong?
Where am I wrong?
'use strict';
var convertBase = function () {
function convertBase(baseFrom, baseTo) {
return function (num) {
return parseInt(num, baseFrom).toString(baseTo);
};
}
// hexadecimal to binary
convertBase.hex2bin = convertBase(16, 2);
return convertBase;
}();
var newMsg = convertBase.hex2bin('ff'); // '11111000'
return newMsg;
Writes an error "Function tried to send a message of type string"
They need a string. How to do it?
Thank you.
A quick search in the forum for "Function tried to send a message of type " would have saved you here.
In short, A function node must always return either the original message or a new object. The preference being returning the original msg
// Your code here
msg.payload = call_your_function(x)
return msg
Ps, did you use an AI for that function? It's a bit over the top! Something like below is all this really needs
const hex = "FF" // or msg.payload
msg.payload = (parseInt(hex, 16).toString(2)).padStart(8, '0')
return msg
system
Closed
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.