From 4ae69c1d69e244d5913f93f87a1fbc07a9a66d3d Mon Sep 17 00:00:00 2001 From: Chulinuwu Date: Thu, 19 Dec 2024 20:25:45 +0700 Subject: [PATCH] fix:lint --- src/lib/api/login.ts | 36 ++++++++++++++--------------- src/routes/api/login/+server.ts | 40 ++++++++++++++++----------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/lib/api/login.ts b/src/lib/api/login.ts index d8a027d..eea3d06 100644 --- a/src/lib/api/login.ts +++ b/src/lib/api/login.ts @@ -1,22 +1,22 @@ const API_URL = '/api/login'; export async function login(studentId: string, password: string) { - try { - const response = await fetch(API_URL, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ studentId, password }) - }); + try { + const response = await fetch(API_URL, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ studentId, password }) + }); - if (!response.ok) { - throw new Error('Login failed'); - } + if (!response.ok) { + throw new Error('Login failed'); + } - const data = await response.json(); - return data; - } catch (error) { - console.error(error); - throw error; - } -} \ No newline at end of file + const data = await response.json(); + return data; + } catch (error) { + console.error(error); + throw error; + } +} diff --git a/src/routes/api/login/+server.ts b/src/routes/api/login/+server.ts index eb3982e..d83582b 100644 --- a/src/routes/api/login/+server.ts +++ b/src/routes/api/login/+server.ts @@ -1,26 +1,26 @@ import type { RequestHandler } from '@sveltejs/kit'; export const POST: RequestHandler = async ({ request }) => { - const { studentId, password } = await request.json(); + const { studentId, password } = await request.json(); - const response = await fetch(`${import.meta.env.VITE_SERVER_URL}/api/v1/auth/login`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ student_id: studentId, password }) - }); + const response = await fetch(`${import.meta.env.VITE_SERVER_URL}/api/v1/auth/login`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ student_id: studentId, password }) + }); - if (!response.ok) { - return new Response(JSON.stringify({ error: 'Login failed' }), { - status: response.status, - headers: { 'Content-Type': 'application/json' } - }); - } + if (!response.ok) { + return new Response(JSON.stringify({ error: 'Login failed' }), { + status: response.status, + headers: { 'Content-Type': 'application/json' } + }); + } - const data = await response.json(); - return new Response(JSON.stringify(data), { - status: 200, - headers: { 'Content-Type': 'application/json' } - }); -}; \ No newline at end of file + const data = await response.json(); + return new Response(JSON.stringify(data), { + status: 200, + headers: { 'Content-Type': 'application/json' } + }); +};