const handleSubmit = (event) => {
event.preventDefault()
const data = { atmName: '', atmType: '', terminalId: '', branchName: '', branchCode: '', branchAddress: '', vendor: '', createdBy: '' }
axios.post(`${apiAddress}/atmterminal/single`, data).then(function (response) {
console.log(response)
})
.catch(function (error) {console.log(error)})
setTerminal(initialFormState);
}
请告诉我这个代码出了什么问题,因为我得到了错误400
首先尝试控制台将您的请求记录到API,看看您发送的请求是否有问题。
正如Adel在评论中所说,400是一个无效的请求,所以你的语法可能有问题。
编辑:
- 你定义了apiAddress吗
- 它是否应该是atmTerminal,遵循其他参数的语法