在Reaction-Router中,当表单提交时,我使用action向后端发送POST请求.这些都是正常工作的问题是我想返回响应和来自后端的错误.然后,我在AXIOS和CATCH函数中返回这些函数,但在UI中它显示为未定义.
export async function registerAction({ request }) {
const formData = await request.formData();
const response = await apiClient.get("/sanctum/csrf-cookie").then((response) => {
apiClient
.post("/register", {
first_name: formData.get("first_name"),
last_name: formData.get("last_name"),
full_name: formData.get("full_name"),
email: formData.get("email"),
//birthday: formData.get("birthday"),
address: formData.get("home_address"),
phone_no: formData.get("phone_number"),
ssn: formData.get("ssn"),
password: formData.get("password"),
password_confirmation: formData.get("password_confirmation"),
})
.then((response) => {
return response;
})
.catch((errors) => {
return errors;
});
});
return null;
}