SuperAgentによるHttp Requestのレスポンスで、カスタムヘッダーが取得できません。
Webアプリの開発として、フロントとバックを別プロジェクトで開発しているのですが、
フロントからのリクエストはtokenをヘッダーに忍ばせる仕様になっております。
このtokenをログインAPIのレスポンスで、カスタムヘッダーから取得したいのですが、
SuperAgentでのカスタムヘッダーの取得方法がわかりません。
Chromeの開発ツールでは確認しているので、項目としては存在しているはずなのですが。。。
わかる方がいらっしゃれば、お願い致します。
SuperAgentのコードは下記の通りです。
static post(path, header={}, body={}) { header['Accept'] = 'application/json'; header['Content-Type'] = 'application/x-www-form-urlencoded'; return new Promise(function(resolve, reject) { Request .post(path) .set(header) .send(body) .end(function(err, res) { console.log(res.xhr.getResponseHeader('Link')); console.log(res); console.log(res.headers); if (!err) { resolve({ status : res.status, json : JSON.parse(res.text), }); } else { resolve({ status : res.status, json : {}, }); } }); }); }
SuperAgentからのレスポンスで、headersの内容は下記の通りです。
headers : { cache-control : "max-age=0, private, must-revalidate", content-type : "application/json; charset=utf-8", }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/11 07:52
2018/01/11 10:19
2018/01/11 12:54
2018/01/11 13:41