我有以下代码来获取JSON数据:
fetch('https://jsonplaceholder.typicode.com/todos')
.then(function(response){
console.log(response)
})
.catch(function(ex){
console.log(ex)
})
当我从文件系统运行它时,我得到以下内容:
Failed to load https://jsonplaceholder.typicode.com/todos: The 'Access-Control-Allow-Origin' header contains multiple values 'http://evil.com/, *', but only one is allowed. Origin 'null' is therefore not allowed access. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
app.js:7 TypeError: Failed to fetch
我已经安装了CORS chrome插件并且已启用,但我仍然收到消息。有什么想法吗?