window.endpoint = "http://localhost:3000"


window.checkToken = async () => {
    if(localStorage.token) {
        const meRequest = await fetch(window.endpoint + "/auth/me", {
            headers: {
                Authorization: localStorage.token
            }
        })
    
        if(!meRequest.ok) {
            localStorage.token = ""
            location.href = "/"
        }

        return await meRequest.json()
    }
}