From 7cbfa84bf82823c8102ba19039f92db45bb00436 Mon Sep 17 00:00:00 2001 From: libexi01 Date: Thu, 18 Jul 2024 01:06:59 +0530 Subject: [PATCH] 27 --- app.db | Bin 12288 -> 12288 bytes s1/src/routes/faculty/login/+page.server.ts | 32 ++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 s1/src/routes/faculty/login/+page.server.ts diff --git a/app.db b/app.db index 4197499a0ce513c8228c60789cc7fe8079041e49..1f0450b4416c4344d080533111759ea1916b8a36 100644 GIT binary patch delta 124 zcmZojXh@hK&B!`Y#+i|IW5N=C9u|IA2L6-$^Y{z+T{jB~nDT3DvamDAimP+TI#!kz zXXGa4IVI+0W~U`)r#j>&X6EQ6=jRqA78jT27o|)tke|ZC!oPxne+BPcD$3!o|$Li-G?s|9Sph Rn*|l7^G|FLoxDrm4FDFw5~u(G diff --git a/s1/src/routes/faculty/login/+page.server.ts b/s1/src/routes/faculty/login/+page.server.ts new file mode 100644 index 0000000..0b858af --- /dev/null +++ b/s1/src/routes/faculty/login/+page.server.ts @@ -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, + }; + } + }, +} \ No newline at end of file