Error: Request failed with status code 401
Error:
// Access to personal information
export const getUserInfoAPI = () => {
return request({
url: '/v1_0/user/profile',
method: 'GET',
Headers: {
Authorization: `Bearer ${getToken()}`
}
})
}
Correct practice
// Access to personal information
export const getUserInfoAPI = () => {
return request({
url: '/v1_0/user/profile',
method: 'GET',
headers: {
Authorization: `Bearer ${getToken()}`
}
})
}
In the process of writing request headers, the use of headers
did not notice the case problem!!!
Read More:
- [Solved] Console Error: Error: Request failed with status code 405
- The page console error [Vue warn]: Invalid prop: custom validator check failed for prop “status“
- [Solved] Vue item packaging error: Failed to load resource: the server responded with a status of 404 (Not Found)
- Failed to execute ‘setRequestHeader’ on ‘XMLHttpRequest’: String contains non ISO-8859-1 code point.
- Vue displays 404 and 500 interfaces according to HTTP response status
- [Solved] bug: error Command failed with exit code 1.
- Solve the asynchronous execution of callback function in Axios request processing interceptor
- Interface request error 504 gateway time out [How to Solve]
- request.js?b775:101 Uncaught (in promise) Error: Failed to convert value of type ‘java.lang.String’ to required type ‘java.lang.Long’;
- [Solved] npm run start Error: Exit status 3221225477
- [Solved] Vue3 npm ERR code ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC
- [Solved] error C:\Users\HP\Desktop\VueProject\vue_cli\node_modules\node-sass: Command failed.Exit code: 1
- [Solved] nodejs Error: request entity too large
- JS getting ${pageContext.request.contextPath} Get the root path of the project
- If the request parameter is formdata, use the Ajax operation
- [Solved] node.js request Error: Error: unable to verify the first certificate
- Trigger http request when tab page is closed in angular2+ project
- Difference between contenttype and datatype in Ajax request of jquery
- Postman Error: Could not send request [How to Solve]
- [Solved] Font End Image Display Error: net::ERR_CONNECTION_RESET 431 (Request Header Fields Too Large)