在我的Chrome扩展中,使用Fetch功能会出错,它不会发送cookie
我想调用提取函数以在我的背景中从服务器获取一些数据。 像这样:
fetch("https://api.bilibili.com/x/space/acc/info?mid=402655790&jsonp=jsonp")
.then(response=>{
console.log(response)
})
但是控制台打印 错误描述照片
我找到了一些解决此问题的方法。 使用模式:“ no-cors”
最后,我成功发送了一个请求,但是没有响应。
此外,我发现我的请求标题中没有cookie
我如何成功发送请求,并从服务器中获取正确的数据?
I want to call fetch function to get some data from the server in my background.js。
like this:
fetch("https://api.bilibili.com/x/space/acc/info?mid=402655790&jsonp=jsonp")
.then(response=>{
console.log(response)
})
but the console print
error description photo
I found some method to solve this problem。
use mode:"no-cors"
Finally, I successfully sent a request,but there was no response.
request success,status code ==200 photo
Besides, I found there is no cookie’s in my request header
no cookies in request header photo
How can I send a request successfully,and get the correct data from the server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现有一个与我的问题类似的答案,
CORS Chrome Extension带有明显版本2 。
这个问题是由CORS引起的。
可以通过在清单中添加权限来解决。
像这样:
I found that there was an answer similar to my question,
CORS Chrome Extension with manifest version 2。
this problem is caused by CORS。
it can be solved by adding permissions to the manifest.json
like this: