post-etch方法使用占位符typecode不起作用


fetch('https://jsonplaceholder.typicode.com/posts', {
method: 'POST'
}).then(function (response) {
// The API call was successful!
if (response.ok) {
return response.json();
} else {
return Promise.reject(response);
}
}).then(function (data) {
// This is the JSON from our response
console.log(data);
}).catch(function (err) {
// There was an error
console.warn('Something went wrong.', err);
});

后提取方法不起作用尝试下面的代码没有响应任何响应可能是什么原因请引导

获取失败的网络err_failed典型代码占位符

或可能访问以获取https://jsonplaceholder.typicode.com/posts'来自原点'https://cdpn.io'已被CORS策略阻止:请求的资源上不存在"Access Control Allow Origin"标头。如果不透明响应满足您的需求,请将请求的模式设置为"无cors",以在禁用cors的情况下获取资源。

请完全删除提取选项对象

{ method: 'POST' }

从您的电话中。

此调用应该是GET,而不是POST

最新更新