Reactjs 表单数据请求标头的格式错误
我有一个http get请求,它向本地服务器发送一些数据。在开发工具中,我看到以下内容: 格式错误,服务器无法正确读取。正确的答案是: 全名:乔治Reactjs 表单数据请求标头的格式错误,reactjs,http,Reactjs,Http,我有一个http get请求,它向本地服务器发送一些数据。在开发工具中,我看到以下内容: 格式错误,服务器无法正确读取。正确的答案是: 全名:乔治 电话:xxxxxx 我做错了什么 const form = new FormData(); form.append("fullname","george"); form.append("phone","xxxxxx"); fetch('http://localhost:3000/', { method: 'po
电话:xxxxxx 我做错了什么
const form = new FormData();
form.append("fullname","george");
form.append("phone","xxxxxx");
fetch('http://localhost:3000/', {
method: 'post',
headers: {'Content-Type':'application/x-www-form-urlencoded'},
body: form
}).then((res)=>{
console.log(res)
});
将“内容类型”:“application/x-www-form-urlencoded”更改为“内容类型”:“application/json”,然后重试again@BabakYaghoobi但是表单数据不是json格式的。对吗?对,但作为json发送到服务器,body:json.stringify(form)@BabakYaghoobi,但我不想作为json发送。