Remove localStorage support because it breaks ssr

This commit is contained in:
pikiou
2022-02-02 14:11:43 +01:00
parent b21b77e513
commit 3264336aab
5 changed files with 12 additions and 16 deletions

View File

@@ -3,24 +3,18 @@ import Cookies from "js-cookie"
import { VolunteerLogin } from "./volunteers"
const storage: any = localStorage
export const axiosConfig: AxiosRequestConfig = {
headers: {},
}
export function setJWT(token: string, id: number): void {
axiosConfig.headers.Authorization = `Bearer ${token}`
storage?.setItem("jwt", token)
storage?.setItem("id", id)
Cookies.set("jwt", token, { expires: 3650 })
Cookies.set("id", `${id}`, { expires: 3650 })
}
export function unsetJWT(): void {
delete axiosConfig.headers.Authorization
storage?.removeItem("jwt")
storage?.removeItem("id")
Cookies.remove("jwt")
Cookies.remove("id")