Hi, I am trying to get the file list of mysite use javascript fetch
var url = api_base + "files/path/home/" + username + "/mysite/"
fetch(url, {
headers: {
'Authorization': 'Token '+api_token
},
method: 'GET',
})
.then(response => {console.log(response)})
It gives me CORS error: Access to fetch at 'https://www.pythonanywhere.com/api/v0/user/shihm714/files/path/home/shihm714/mysite/' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
If I run a similar request in Python, it works totally fine. What's the mistake in my js code and settings? Please help me, thank you!