Search code examples
node.jsexpresshttp-headersresponseresponse-headers

Node Express res.set() not working


I'm implementing jwt bearer on my app. On my route controller block I have this :

utils.createToken({ email: user.email}, function(token){
    res.set({'Authorization': 'Bearer ' + token});
    res.status(200).json(user);
})

But on the response object there's nothing on the header : enter image description here

What did I missed? Thanks.


Solution

  • There is nothing obviously wrong with the Express server-side code to set the header.

    The headers field shown in the response object is a function that returns a header or headers. Calling console.log(response.headers()) in the browser will show the full response header contents.