Help with API Token and message

Hello,

I'm using API with bearer auth and http request node. I have a function to set the token and 2 inputs as JSON. Atm I'm using it like this:

This is the function:

msg.headers = {
    Authorization: "Bearer "+ flow.get("Token")
};
return msg;
 

The way I did show above works, but it looks not the way it should be done.

Is there a way to combine messages with 2 topics? Can it be done with join node?

I need to have msg.payload and msg.headers for auth

When you trigger the inject node it will send one message to the Function node and one to the Request node.

As you want the Function node to set msg.headers before the message is passed to the Request node, delete the wires connecting the Inject and Request nodes.

well, it works, thank you very much.

I thought my object will just be overwritten with msg.header...

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