Hi.
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.
Thanks
/Robert
Yes, if you use JSONata.
set msg.
payload.accessToken
to the value of "Bearer " & payload.accessToken
ghayne
3 February 2022 13:51
3
Welcome to the forum!
Try this in a change node, using JSONata.
1 Like
ghayne
3 February 2022 13:52
4
@Steve-Mcl beat me to it!
1 Like
Damn you guys are fast
Thanks. That's really easy.
ghayne
3 February 2022 13:55
7
Steve,
I think that in terms of node-red knowledge then: @Steve-Mcl > @ghayne
2 Likes
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 global.id using another change node.
in the combine job i'm trying :
"https://api.easee.cloud/api/chargers/ " & global.id & "/state"
But the global.id is just empty.
Any idea on what i'm doing wrong.
And thanks in advance
E1cid
3 February 2022 14:40
9
You failed to mention global.id
is that a context global called id. If so it would be globalContext("id")
.
1 Like
E1cid:
globalContext("id")
Thanks. That was the error.
I had to set a $ in front, to make it work.
But it's working like this :
"https://api.easee.cloud/api/chargers/ " & $globalContext("id") & "/state"
system
Closed
17 February 2022 15:24
11
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.