Passing JWT in headers with axios

前端 未结 1 1150
星月不相逢
星月不相逢 2021-02-04 04:27

I\'ve created a small project with a node back-end and react front-end to fetch the data through REST calls. I used Axios library, but when I pass the headers w

相关标签:
1条回答
  • 2021-02-04 04:40

    You need to concatenate 'Bearer ' before the token, like this:

    axios.defaults.headers.common['Authorization'] = 
                                    'Bearer ' + localStorage.getItem('jwtToken');
    
    0 讨论(0)
提交回复
热议问题