如何获取 Azure 函数中的请求 header ?我使用 JavaScript http 触发器来处理请求。我需要从前端读取请求 header 中发送的一些 token 。我该如何做到这一点?
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();
};
最佳答案
使用req.headers
,例如
module.exports = function (context, req) {
context.log('Header: ' + req.headers['user-agent']);
context.done();
};
关于javascript - 在azure函数NodeJs Http触发器中获取请求 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47890653/