我可以从 localStorage 检索 JWT 令牌并将其req.body发送到headers.Authorization. 我可以在客户端记录令牌,但不会在服务器上收到它。
客户:React、Redux-Saga。
function* getInitialStateFetch(){
var actionType = 'GET_INITIALSTATE_REDUCER';
var path = 'react/listings28';
var token = localStorage.getItem('my_tkn');
console.log(token) // logs token
var httpHeaders;
if(token){
httpHeaders = {
'Content-Type' : 'application/x-www-form-urlencoded',
'Accept' : 'application/json',
'Authorization' : `Bearer ${token}`
};
} else {
httpHeaders = {
'Content-Type' : 'application/x-www-form-urlencoded',
'Accept' : 'application/json'
};
}
let options = {
method: 'GET',
mode: 'no-cors',
headers: new Headers(httpHeaders),
credentials: 'same-origin'
};
yield call(apiCall, path, options, actionType);
} …Run Code Online (Sandbox Code Playgroud) 我有
"html.autoClosingTags": false,
"editor.autoClosingBrackets": false
Run Code Online (Sandbox Code Playgroud)
在我的设置中,它对除HTML注释之外的所有标签都适用。当我输入时,<!--它会自动完成-->。我浏览了编辑器和HTML中的其他选项,找不到如何将其关闭。
autocomplete ×1
comments ×1
express ×1
fetch-api ×1
html ×1
http-headers ×1
react-redux ×1
reactjs ×1