Answer the question
In order to leave comments, you need to log in
Why is the Bearer token not being sent to the server via fetch?
This is my fetch
let token = 'bt8lIQORNofZ3Kd11bACdpl6xqZt87eY;
let headers = new Headers();
headers.set('Authorization', 'Bearer ' + token);
fetch('http://back.ru/menu?tree=1', {
credentials: "include",
headers: {
headers
},
})
.then(response => response.json()).then(data => { context.commit('SET_LIST', data) });
Answer the question
In order to leave comments, you need to log in
As a result, I found out that the server does not see the headers if they were sent through the object new Headers()
, and when I added the headers manually, like this:
headers: {
'Authorization': 'Bearer ' + token
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question