Format variable with string + variable in change node


In a function node, i can create :
msg.payload.accessToken = "Bearer "+ msg.payload.accessToken;

when i wan't to combine a string + variable.
But is there a way to do the same in a change node.
There seams to be a lot of option the the change node, but i can't quite figure out how to do this.



Yes, if you use JSONata.
set msg. payload.accessToken
to the value of "Bearer " & payload.accessToken

Welcome to the forum!

Try this in a change node, using JSONata.

1 Like

@Steve-Mcl beat me to it!

1 Like

snap :smiley:

Great minds & all :wink:

1 Like

Damn you guys are fast :slight_smile:

Thanks. That's really easy. :pray:

I think that in terms of node-red knowledge then: @Steve-Mcl > @ghayne :slight_smile:


Sorry but i have to ask again.

Took it a bit further, but the variable does not get reconized, so the result is 2 combined strings, without the variable.

I'm setting a global variable somewhere else in my job to using another change node.

in the combine job i'm trying :

"" & & "/state"

But the is just empty.

Any idea on what i'm doing wrong.

And thanks in advance :slight_smile:

You failed to mention is that a context global called id. If so it would be globalContext("id").

1 Like

Thanks. That was the error.
I had to set a $ in front, to make it work.

But it's working like this :
"" & $globalContext("id") & "/state"

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