const onSubmit = async (data: FormData) => {
try {
const apiUrl = process.env.NEXTAUTH_URL;
const response = await fetch(`${apiUrl}/api/user`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: data.email,
password: data.password,
}),
});
if (response.ok) {
console.log("User created successfully!");
setConfirm(true);
// Handle success or redirect to another page if needed
} else {
console.error("Failed to create user.");
// Handle errors, show error messages, etc.
}
} catch (error) {
console.error("Error occurred:", error);
// Handle network errors or other exceptions
}
};
const onSubmit = async (data: FormData) => {
try {
const apiUrl = process.env.NEXTAUTH_URL;
const response = await fetch(`${apiUrl}/api/user`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: data.email,
password: data.password,
}),
});
if (response.ok) {
console.log("User created successfully!");
setConfirm(true);
// Handle success or redirect to another page if needed
} else {
console.error("Failed to create user.");
// Handle errors, show error messages, etc.
}
} catch (error) {
console.error("Error occurred:", error);
// Handle network errors or other exceptions
}
};