How do I get the request headers in Azure functions ? I use JavaScript http trigger to handle a request. I need to read some token sent in the request header from the front end. How can I do this ?
module.exports = function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
if (true) {
context.log(req.headers['Authorization'])
context.res = {
// status: 200, /* Defaults to 200 */
body: "Hello there "
};
}
else {
context.res = {
status: 400,
body: "Please pass a name on the query string or in the request body"
};
}
context.done();
};
Use req.headers
, e.g.
module.exports = function (context, req) {
context.log('Header: ' + req.headers['user-agent']);
context.done();
};