Javascript POST请求为空
我尝试向DB发送表单值(使用redux thunk、express和MongoDB)。我的组件看起来像Javascript POST请求为空,javascript,forms,post,axios,redux-thunk,Javascript,Forms,Post,Axios,Redux Thunk,我尝试向DB发送表单值(使用redux thunk、express和MongoDB)。我的组件看起来像 const AddPerson=(道具)=>{ const[person,setPerson]=useState({ 名称:“”, 年龄:'', 状态:“” }) 常量handleChange=(事件)=>{ 塞特珀森({ …人, [event.target.name]:event.target.value }) } const handleSubmit=(事件)=>{ props.putC
const AddPerson=(道具)=>{
const[person,setPerson]=useState({
名称:“”,
年龄:'',
状态:“”
})
常量handleChange=(事件)=>{
塞特珀森({
…人,
[event.target.name]:event.target.value
})
}
const handleSubmit=(事件)=>{
props.putCustomerData({person})
//eslint禁用下一行无控制台
控制台日志(个人)
event.preventDefault()
}
返回(
名称
年龄
地位
好啊
);
}
AddPerson.propTypes={}
AddPerson.defaultProps={
人:{}
}
常量mapStateToProps=状态=>({
个人:国家、个人、数据
})
const mapDispatchToProps=dispatch=>bindActionCreators({PutCustomerData},dispatch)
导出默认连接(MapStateTops,mapDispatchToProps)(AddPerson)
您的axios.post(…)
调用的参数顺序错误。
你有:
axios.post('someUrl'{
标题:{
“内容类型”:“应用程序/json”,
},
正文:{person}
})
正确的顺序是:
axios.post('someUrl'{
{个人},
标题:{
“内容类型”:“应用程序/json”,
}
})
从
post(url[,数据[,配置]])
axios.post(…)
调用的参数顺序错误。
你有:
axios.post('someUrl'{
标题:{
“内容类型”:“应用程序/json”,
},
正文:{person}
})
正确的顺序是:
axios.post('someUrl'{
{个人},
标题:{
“内容类型”:“应用程序/json”,
}
})
从
post(url[,数据[,配置]])