Store txt content into a variable

hey hello guys

I guess this is a trivial problem, but I just don't get it. I want to store a numbre from a txt file into a variable.
I only have one number in the txt file. I want to store it into "count". The problem with my code is that he don't only stores the number, but also the additional info (see image). When I manually store a number into a variable, it works. See code below: Into "count" I store the payload from the txt file. Into "countertest" I store a number directly.

var counter = {payload: msg.payload};
var count=flow.get('count') || 0;
var countertest=flow.get('countertest') || 4;
flow.set('count', counter);
flow.set('countertest', countertest);
return counter;

counter

[{"id":"20ddb1cc.3f763e","type":"debug","z":"15c97f36.c1cd71","name":"get counter debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":240,"wires":[]}]

You are creating an object. Don't. Just put the value of msg.payload into the counter.

var counter = Number(msg.payload);
1 Like

exactly what I was looking for, thank you so much :))

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