【发布时间】:2020-09-30 21:45:10
【问题描述】:
我正在尝试从注册表单向使用 json 服务器制作的假 api 发出发布请求,但我不断收到错误 400 Bad Request。
const managerRegister = () => {
const [manager, setManager] = useState({
email: "",
password: "",
confirmPassword: "",
accessLevel: 2,
company: "",
})
console.log(manager)
const handleSubmit = (values) => {
axios.post(`https://reembolsa-ai-api.herokuapp.com/register`, manager)
.then(res => setManager(res))
.catch(error => console.log(error))
}
I'm using an ant-design form so it already comes with a function onFinish that handles the actions to be taken when the form is submitted
const onFinish = (values) => {
handleSubmit(values)
};
我尝试在 useEffect 中使用 axios 请求,但它也不起作用。
})
我需要将这些信息传递给 api。我试过了
【问题讨论】:
-
status 400 表示您正在向服务器发送不正确的内容。请查看您的网络标签以获取更多信息。
标签: reactjs axios react-hooks