javascript - Vuejs get token from header - Stack Overflow

I have a response from server and there are auth token, max age and some other values. In Postman it lo

I have a response from server and there are auth token, max age and some other values. In Postman it looks like:

I want to set it to localStorage but have no idea how to get value in vuejs file, I tried this code:

this.$http.post('http://localhost:8081/login', data)
        .then(response =>{
          console.log(response.header.Authorization);
        })

but there is an error:

Uncaught (in promise) TypeError: Cannot read property 'Authorization' of undefined

how it it possible to read my token from header?

I have a response from server and there are auth token, max age and some other values. In Postman it looks like:

I want to set it to localStorage but have no idea how to get value in vuejs file, I tried this code:

this.$http.post('http://localhost:8081/login', data)
        .then(response =>{
          console.log(response.header.Authorization);
        })

but there is an error:

Uncaught (in promise) TypeError: Cannot read property 'Authorization' of undefined

how it it possible to read my token from header?

Share Improve this question asked Mar 5, 2017 at 18:28 littlewombatlittlewombat 3092 gold badges8 silver badges22 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

Use headers

response.headers.get('Authorization');

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745314169a4622137.html

相关推荐

  • javascript - Vuejs get token from header - Stack Overflow

    I have a response from server and there are auth token, max age and some other values. In Postman it lo

    10小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信