Created
April 24, 2023 10:07
-
-
Save Sklavit/7825b0bb03da399bcfc4ac6482440221 to your computer and use it in GitHub Desktop.
localStorage based Auth
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
const token = localStorage.getItem('token') | |
const response = await fetch(apiURL, { | |
method: 'POST', | |
headers: { | |
'Content-type': 'application/json', | |
'Authorization': `Bearer ${token}`, // notice the Bearer before your token | |
}, | |
body: JSON.stringify(yourNewData) | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment