fix: fixed register page

This commit is contained in:
Lukian 2025-03-25 14:20:55 +01:00
parent 90a6b6fa63
commit 414be922bc
3 changed files with 19 additions and 17 deletions

View file

@ -9,17 +9,18 @@ export default function Register () {
function handleSubmit(e: React.FormEvent) {
e.preventDefault();
axios.post("/api/auth/register", { username, password });
axios
.post("/api/auth/login", { username, password })
.then((res) => {
localStorage.setItem("token", res.data.token);
navigate("/");
})
.catch((err) => {
alert(err.response.data.message);
}
);
axios.post("/api/auth/register", { username, password }).then(() => {
axios
.post("/api/auth/login", { username, password })
.then((res) => {
localStorage.setItem("token", res.data.token);
navigate("/");
})
.catch((err) => {
alert(err.response.data.message);
}
);
});
}
return (