Files
archtika/web-app/src/routes/(anonymous)/register/+page.server.ts

23 lines
546 B
TypeScript
Raw Normal View History

2024-07-31 07:23:32 +02:00
export const actions = {
default: async ({ request, fetch }) => {
const data = await request.formData();
const res = await fetch("http://localhost:3000/rpc/register", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
username: data.get("username"),
password: data.get("password")
})
});
const response = await res.json();
if (!res.ok) {
return { success: false, message: response.message };
}
return { success: true };
}
};