Files
gold_land_user/src/api/token.ts
T

23 lines
458 B
TypeScript
Raw Normal View History

const TOKEN_KEY = 'gold-land-auth-token'
let authToken: string | null = null
export function getAuthToken(): string | null {
if (authToken) return authToken
try {
return localStorage.getItem(TOKEN_KEY)
} catch {
return null
}
}
export function setAuthToken(token: string | null) {
authToken = token
try {
if (token) localStorage.setItem(TOKEN_KEY, token)
else localStorage.removeItem(TOKEN_KEY)
} catch {
// ignore
}
}