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?
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:
"permissions": [
"https://*/"
],