const handleSignup = async (event) => {
event.preventDefault();
try {
const response = await fetch("http://localhost:5000/signup", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ betaKey, email, password }),
credentials: "include",
});
const data = await response.json();
if (!response.ok) {
console.error(
`status ${response.status}, text: ${response.statusText}`
);
throw new Error(data.message || "Något gick fel.");
}
if (data.success) {
navigate("/stats");
}
} catch (error) {
setError(error.message);
console.error("An error occurred during signup", error.message);
}
};