How to convert a number to a string in Node-RED?

Hi dears
I want to convert the output of CPU usage from a number to a string. Please help me with the right code for the function block. I am new to Node-RED.

Why? In general, you don't need to do that.

1 Like

When I connect the CPU usage block directly to the HTTP response, the server doesn't return any response to the client and displays the "no response object." So I want to convert the number to a string and try again.

The issue is not the format of your data, the CPU node is deleting the original msg. But the response node requires msg.res to respond, but it has been deleted and is no longer available to the http response node. Set your debug nodes to show full message , then you will see that after http in there is a msg.res, but after CPU it has been removed. You will have to pass it round the CPU node or save it to context, or use another CPU node that does not overwrite the OG msg. msg.res has to make it to the response node.

1 Like

And ideally report it as an issue against that node (if it is still maintained)

1 Like

Thank you dear, it got solved.

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