0
I’m in the middle of a course where on a provisional basis we’re using a fixed token validator in the application in this way:
require('axios').defaults.headers.common['Autorization'] = `bearer ${token}`
This returns an error in the console:
xhr.js?b50d:184 GET http://localhost:3000/users 401 (Unauthorized)
...
The function is as follows:
loadUsers() {
const url = `${baseApiUrl}/users`;
axios
.get(url)
.then((res) => {
this.users = res.data;
});
},
The base url is imported from an external file.
Using Postman I get access to the bank normally and it validates whether or not the user is administrator, but by the application it seems that not even recognize as logged in the way it is... Any hint of what might be happening?
Link to the repository: https://github.com/omnweb/Knowledge-Base-Project
Great, thanks for the answer. Is this code from the finished version? I did not conclude yet, I stopped at the part that he said would leave the above code as provisional, only that for me it did not work and from what I could notice he only changes this part of the token code at the end of the course.
– Neto Matiazi