This commit is contained in:
2024-07-18 01:06:59 +05:30
parent 3357948954
commit 7cbfa84bf8
2 changed files with 32 additions and 0 deletions

BIN
app.db

Binary file not shown.

View File

@@ -0,0 +1,32 @@
import type { Actions } from "@sveltejs/kit";
import { redirect } from '@sveltejs/kit';
export const actions: Actions = {
default: async ({ request }) => {
// console.log(request.json());
var endpoint = "http://localhost:8082/controller/faculty";
var data = await request.formData();
var res = await fetch(endpoint.concat("?em=", String(data.get('em')), "&pw=", String(data.get('pw'))), {
method: "POST",
headers: {
"Content-Type": "application/json",
},
// body: JSON.stringify(data),
})
console.log(res);
var data1 = await res.json();
console.log(data1);
if (res.ok) {
// Successful fetch
throw redirect(303, '/'); // Redirect to success page
} else {
// Handle error
return {
error: data1.msg,
};
}
},
}