由mozilla
var url = 'https://example.com/profile';
var data = {username: 'example'};
fetch(url, {
method: 'POST', // or 'PUT'
body: JSON.stringify(data), // data can be `string` or {object}!
headers:{
'Content-Type': 'application/json'
}
}).then(res => res.json())
.then(response => console.log('Success:', JSON.stringify(response)))
.catch(error => console.error('Error:', error));
我尝试过这样,但是它给了我{“ Message”:“处理请求时出错。”,“ StackTrace”:“”,“ ExceptionType”:“”}
我发送这样的字符串:body:JSON.stringify('CL_VA_Rihtim')
不!您必须将参数作为字典JSON.stringify({'NameParameter':'value'})发送