目录
之前使用x-www-form-urlencoded方式传递参数能正常返回:
fetch--post-- json请求报错
fetch('http://localhost:3000/books', {
method: 'post',
body: JSON.stringify({
uname: 'zhangsan',
pwd: '456'
}),
headers: {
'Content-Type': 'application/json'
}
})
.then(function(data) {
// return data.text();
return response.json();
}).then(function(data) {
console.log(data);
})
1.报错提示: