From 94d5d89aa59b6d1e53dab280c26e3a8fcb22b7e4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 1 Aug 2024 21:13:11 +0900 Subject: refactor(frontend): provide simpler API client --- frontend/app/.server/auth.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'frontend/app/.server/auth.ts') diff --git a/frontend/app/.server/auth.ts b/frontend/app/.server/auth.ts index b80166b..b7e1820 100644 --- a/frontend/app/.server/auth.ts +++ b/frontend/app/.server/auth.ts @@ -3,22 +3,13 @@ import { FormStrategy } from "remix-auth-form"; import { jwtDecode } from "jwt-decode"; import type { Session } from "@remix-run/server-runtime"; import { sessionStorage } from "./session"; -import { apiClient } from "./api/client"; +import { apiPostLogin } from "./api/client"; import { components } from "./api/schema"; export const authenticator = new Authenticator(sessionStorage); async function login(username: string, password: string): Promise { - const { data, error } = await apiClient.POST("/login", { - body: { - username, - password, - }, - }); - if (error) { - throw new Error(error.message); - } - return data.token; + return (await apiPostLogin(username, password)).token; } authenticator.use( -- cgit v1.2.3-70-g09d2