Best way to concatenate content over time?

I do have a process consisting of several functions and api calls which is looped until all api responses have been processed. every time a loop cycle ends, there is some content being generated (f.e. "result of loop 1", "result of loop 2" and so on) I would like show this on the dashboard but need to concat all the content first. I tried to simply grow a variable like flow.processContent += msg.payload.generatedOutput but failed to show this flow variable in the dashboard template. Even my plays with the join node did not really do the job. What would be the best way to achieve this?

Using a flow variable should work. Show us what you have achieved and tell us what isn't working.

Bildschirmfoto 2020-12-16 um 13.22.26

initially I set flow.chickenLocations to "CHICKEN" on the third node.
Bildschirmfoto 2020-12-16 um 13.24.29

on the last function node I modify this flow variable like this (just as poc):

let arr = msg.payload.routes[0];

let dist = arr.distance;
if(dist <= msg.maxDistance)
{
    flow.chickenLocations = flow.chickenLocations + msg.myData.b + "(" + msg.myData.c +")<br>";
    return {locData: msg.myData, payload: msg.payload, distance: dist};
}

the template node should then simply get updated and display that variable with its current content

<div ng-bind-html="flow.chickenLocations"></div>

Nothing is shown on the template node, so I must be doing something wrong....

The first thing I note is that you are not using the recommended way to access context data in a function node as described in the node-red docs.

Apart from that, which bit isn't working? Setting the context data or picking it up in the template?

You also might like to look at the help text for the Template node.

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