Skip to content

Instantly share code, notes, and snippets.

@Danielshow
Last active May 17, 2019 15:15
Show Gist options
  • Save Danielshow/507021287039c06a9f69712fff22f0e5 to your computer and use it in GitHub Desktop.
Save Danielshow/507021287039c06a9f69712fff22f0e5 to your computer and use it in GitHub Desktop.
import jwt from 'jsonwebtoken'
const verifyToken = (req, res) => {
const headers = req.headers['authorization']
if (!headers) {
// any error
}
const token = req.headers.authorization.split(' ')[1]
const user = jwt.verify(token, //secretkey)
req.user = user;
}
res.status(200).json({
data: {},
message: ''
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment