30
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
import type { Actions } from "@sveltejs/kit";
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
function sessionStore(field: string, value: string) {
|
||||
if (browser) {
|
||||
window.sessionStorage.setItem(field, value);
|
||||
}
|
||||
}
|
||||
|
||||
export const actions: Actions = {
|
||||
default: async ({ request }) => {
|
||||
@@ -17,11 +24,15 @@ export const actions: Actions = {
|
||||
})
|
||||
console.log(res);
|
||||
var data1 = await res.json();
|
||||
console.log(data1);
|
||||
|
||||
if (res.ok) {
|
||||
// Successful fetch
|
||||
throw redirect(303, '/'); // Redirect to success page
|
||||
sessionStore('firstName', data1.firstName);
|
||||
sessionStore('lastName', data1.lastName);
|
||||
sessionStore('email', data1.email);
|
||||
sessionStore('password', data1.password);
|
||||
// console.log(window.sessionStorage.getItem('firstName'));
|
||||
throw redirect(303, '/faculty'); // Redirect to success page
|
||||
} else {
|
||||
// Handle error
|
||||
return {
|
||||
|
Reference in New Issue
Block a user