Created
November 11, 2020 23:44
-
-
Save blogcacanid/b05c9052259d579e8eb1a23578e7c953 to your computer and use it in GitHub Desktop.
auth-header.js Authentication JWT React JS Lumen 7
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
export default function authHeader() { | |
const user = JSON.parse(localStorage.getItem("user")); | |
if (user && user.accessToken) { | |
// For Lumen 7 back-end | |
return { Authorization: "Bearer " + user.accessToken }; | |
// for Node.js Express back-end | |
// return { "x-access-token": user.accessToken }; | |
} else { | |
return {}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment