-1 javascript request-headers fetch-api
我正在尝试请求一个需要使用令牌进行身份验证的 REST API。构造 Request 对象时,一些标头会消失。为什么我无法设置授权标头?
let http_headers = {
"Content-type": "application/json",
'Authorization': 'Token token='+my_token,
'Accept': 'Application/json'
};
let url = this.base_url + '/api/v1/test';
let init = {
method: "POST",
headers: new Headers(http_headers),
mode: 'no-cors',
credentials: 'omit' // I try that, but it doesn't seem to have effect
};
let req = new Request( url, init );
console.log(req.headers.get("Accept")); // Application/json
console.log(req.headers.get("Authorization")); // null, why ?
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1432 次 |
最近记录: |