报错原文:
GET http://localhost:8000/api/info/?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjgyNzMxMTcwLCJpYXQiOjE2Nzc1NDcxNzAsImp0aSI6IjZhNTkwZGJkZTU0MzRiNzE5NjlhOWFhMzdmMzQ1M2QzIiwidXNlcl9pZCI6MX0.C4JeWWsra9sUBy_zDOsNUd28LTCVgwJCr82nlONomgM 401 (Unauthorized)
报错原因:未鉴权,header里面的token格式不对
原来是浏览器做数据请求的时候,
此时的token如下图:
改成config.headers['Authorization'] = 'Bearer '+localStorage.getItem('Authorization')之后,成功: