Last active
April 2, 2019 06:55
-
-
Save alur222/c9bbb3e1c061d294606e63b94498cd9c to your computer and use it in GitHub Desktop.
verfying token authenticity from localStorage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// replace LS_ITEM_NAME with your localstorage item name | |
// REACT_APP_BACKEND_HOST | |
// server should accept custom header "x-access-token" | |
export const AuthVerify = async () => { | |
const token = localStorage.getItem(LS_ITEM_NAME); | |
if (!token) { | |
return Promise.reject(false); | |
} | |
return axios.request({ | |
method: 'post', | |
url: `${process.env.REACT_APP_BACKEND_HOST}/auth/verify`, | |
headers: { | |
'x-access-token': token, | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment