我正在请求对mongodb做出反应的api 这是我的构造函数
constructor(){
super();
this.state={
email:'',
eemail:'',
password:'',
epassword:'',
mobile:'',
emobile:'',
isadmin:'yes',
isprinter:'yes',
isuser:'yes',
}
}
然后在表单提交函数中调用api
formSubmit(e){
e.preventDefault();
let error=0;
if(this.state.email===''){
this.setState({eemail:"This field is require"})
error=1
}
if(!error){
console.log(this.state)
const admin = {
email: this.state.email,
password: this.state.password,
mobile: this.state.mobile,
isadmin: this.state.isadmin,
isuser: this.state.isuser,
isprinter: this.state.isprinter,
}
axios.post("http://localhost:5000/admin/add",admin)
.then(res=>console.log(res))
}
}
给我
错误:ValidationError:isuser:路径
isuser
是必需的。isprinter: 路径isprinter
是必需的。isadmin:路径isadmin
是必需的。 即使我通过所有这些参数。 我也尝试过true而不是yes,并且在mongodb模型中有String数据类型