我在客户端组件中使用 NextJS v14.1.0 和服务器操作。我收到了正确的消息,但也收到了一个 TypeError 消息,表明 body 不可用。
src/app/auth/account-verification/page.tsx
const onSubmit = async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
const data = { requestId: token, otp: parseInt(otp) };
const response = await AccountVeficationAction(data);
ActionResponseHandler(response, "Account Verification");
if (response.success) {
Router.push("/auth/login");
}
};
Run Code Online (Sandbox Code Playgroud)
/src/app/auth/_utils/actions/action.ts
export const AccountVeficationAction = async (body: any) => {
try {
const response = await fetch(`${BASEURL}/auth/confirm-account`, {
method: "POST",
headers: {
"Content-Type": "application/json",
// Add other necessary headers (e.g., authorization)
},
body: JSON.stringify(body), // Access data from the …Run Code Online (Sandbox Code Playgroud)