18 lines
354 B
TypeScript
18 lines
354 B
TypeScript
async function getAccessToken() {
|
|
const response = await fetch("/api/user/auth", {
|
|
method: "GET",
|
|
})
|
|
const res = await response.json()
|
|
|
|
if (
|
|
typeof res === "object" &&
|
|
res &&
|
|
"token" in res &&
|
|
typeof res.token === "string"
|
|
)
|
|
return res.token
|
|
|
|
throw new Error("Access token not found")
|
|
}
|
|
|
|
export default getAccessToken
|