New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fetch设置headers失效 #277
Comments
参考 https://www.npmjs.com/package/whatwg-fetch#post-json ,不过你的代码看起来好想也没问题。 |
OK,谢谢,我再尝试一下。 |
Content-Type 是不是该加个引号包起来. |
@xaviertung 该问题你解决了吗,怎么解决的,能否请教下,我折腾了好久还是不行。 |
hi, @huzhengke , @lincenying 的方式应该是正解 |
@monkindey 加引号,按照官网的写法依然没用呀。 |
@huzhengke 请问解决了吗?新人又入坑了。。。。 |
得这样 fetch(
new Request(`${API}${path}`, {
headers: new Headers({ Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' }),
}),
)
.then(res => res.json()); 关键是用 Request 和 Headers 对象。 |
@xaviertung 你把 mode 设置为 'cors' 就行了,不要用 'no-cors' |
请问有解决方法吗 |
@suedar 你看我那个行不行 |
跨域的时候还会出现header缺失问题,只能返回部分header头
|
@sorrycc utils/request.js中设置headers,在浏览器查看http请求,发现未在request headers中生效:
request.js代码:
浏览器中Request Headers显示未生效:
accept:application/json
content-type:text/plain;charset=UTF-8
请教一下,如何设置headers头信息呢?比如将token塞进header中?
The text was updated successfully, but these errors were encountered: