如何使用JWT(承载者令牌)获取身份验证信息

时间:2019-04-09 17:12:19

标签: reactjs laravel axios

我在获取使用JWT Bearer令牌登录的信息时遇到问题,我在登录用户时始终会收到401未经授权的响应。

我的日志:

Logs

我获取用户信息的功能。

componentDidMount()
{

    let token = localStorage.getItem("authorization_code");
    let url = 'http://127.0.0.1:8000/api/auth/me?token=';

    const headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        'Authorization': 'Bearer ' + token 
    }

    console.log('Bearer ' + token );

    axios.post(url,{headers:headers}).
    then(response => {
        console.log(response);
    }).catch(response => {
        console.log(response);
    })

}

0 个答案:

没有答案