2017-12-19 22 views
0

Azure関数でリクエストヘッダーを取得するにはどうすればよいですか?私は、リクエストを処理するためにJavaScriptのhttpトリガを使用します。フロントエンドからリクエストヘッダで送られてきたトークンを読む必要があります。これどうやってするの ?azure関数でリクエストヘッダーを取得するNodeJs Http Trigger

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(); 
}; 
+0

あなたのコードを投稿して、あなたを助けることができますか? – hjm

答えて

0

req.headersを使用してください。

module.exports = function (context, req) { 
    context.log('Header: ' + req.headers['user-agent']); 
    context.done(); 
}; 
+0

ありがとうございます。私はドキュメンテーションのどの部分でも見つけることができませんでした。 –

関連する問題