로그인 구현

This commit is contained in:
static
2024-12-26 19:08:28 +09:00
parent b6fbd83d6f
commit bd1cc9ea38
6 changed files with 44 additions and 7 deletions

View File

@@ -1,6 +1,8 @@
<script lang="ts">
import type { Snippet } from "svelte";
interface Props {
children?: any;
children: Snippet;
color?: "primary" | "gray";
onclick?: () => void;
}

View File

@@ -1,6 +1,7 @@
<script lang="ts">
import type { Snippet } from "svelte";
interface Props {
children?: any;
children: Snippet;
onclick?: () => void;
}

View File

@@ -35,13 +35,13 @@ const callAPIInternal = async (
Authorization: `Bearer ${token}`,
},
});
if (res.status === 401 && retryIfUnauthorized) {
if (res.status === 401 && retryIfUnauthorized && token !== undefined) {
return await callAPIInternal(input, init, null, false);
}
return res;
};
export const callAPI = async (input: RequestInfo, init?: RequestInit, token?: string | null) => {
export default async (input: RequestInfo, init?: RequestInit, token?: string | null) => {
return await callAPIInternal(input, init, token);
};

1
src/lib/hooks/index.ts Normal file
View File

@@ -0,0 +1 @@
export { default as callAPI } from "./callAPI";