var headers = { "Content-Type": "application/json", "Access-Control-Origin": "*" }
尝试将上述行添加到标题中。
var data = { "email": "peter@klaven", "password": "cityslicka" } fetch("https://reqres.in/api/login", { method: "POST", headers: headers, body: JSON.stringify(data) }) .then(function(response){ return response.json(); }) .then(function(data){ console.log(data) });