I use the following code to make a cross-domain request for the post method:
let formData= new FormData();
for (var attr in data) {//datajson
formData.append(attr,data[attr]);
}
fetch(url,{
method:method,
mode:"cors",
headers:{
"Content-Type": "application/json",
"Cross-Method": "CORS",
},
body: formData,
}).then(function(res){
console.log("fetchrequest",JSON.stringify(res.ok));
if(res.ok){
res.json().then(function(json){
console.info(json);
message.success(":"+":\r\n"+json);
});
}else{
message.error(":"+"");
}
}).catch(function(e){
message.error(":"+"");
});
but the following error is displayed:
The
post parameter and the custom header I wrote have no hint at all.
returns a hint of Invalid CORS request
. I don"t know what went wrong.