后端java返回的jwt在header里面,request.js如何提取token并保存呢?

Translation of this issue:
The jwt returned from the back end is inside the header. How does request.js extract the token and save it?

// request
const defaultOptions = {
credentials: 'include',
headers: {},
};
if (newOptions.method === 'POST' || newOptions.method === 'PUT') {
// some code
}
const token = getToken();
if (token) {
newOptions.headers.Authorization = `Bearer ${token}`;
}
// response
return fetch(url, newOptions)
.then(checkStatus)
.then(response => {
const newToken = response.headers.get('authorization');
if (newToken) setToken(newToken);
请问v4 怎么处理
Most helpful comment