Skip to content

Instantly share code, notes, and snippets.

@Sklavit
Created April 24, 2023 10:07
Show Gist options
  • Save Sklavit/7825b0bb03da399bcfc4ac6482440221 to your computer and use it in GitHub Desktop.
Save Sklavit/7825b0bb03da399bcfc4ac6482440221 to your computer and use it in GitHub Desktop.
localStorage based Auth
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