jwtextract
Version:
extract and parse jwt from headers
38 lines (28 loc) • 653 B
Markdown
fast extract your jwt from your authorization header
1. Install with
```bash
$ npm i jwtextract
```
or
```bash
$ yarn add jwtextract
```
```js
import jwtextract from 'jwtextract'
```
```js
export const authenticateUser = async (req, res, next) => {
// sent in the req and expect to get string jwt as return value
const accessToken = jwtextract(req)
if (!accessToken) {
// response with some error
return responseWithError(res, error(FORBIDDEN_MSG, FORBIDDEN))
}
else{
// do your magic code...
}
}
```