我有一个 ReactJS 应用程序,它使用 node.js 和 "proxy": "http://localhost:5000"
与 Mongo 数据库进行通信。当我创建一个新用户时,它返回以下错误:
post- http://localhost:3000/signup 422 (Unprocessable Entity)
这是我的代码:
注册.js
const PostData = () =>{
fetch("/signup",{
method: "post",
headers:{
"content.Type":"application/json"
},
body:JSON.stringify({
name:name,
password:password,
email:email
})
}).then(res=>res.json())
.then(data=>{
if(data.error){
M.toast({html: data.error,classes:"#c62828 red darken-3"})
}
else{
M.toast({html: data.message,classes:"#43a047 green darken-1"})
history.push('/signin')
}
})
}