Skip to content

Commit

Permalink
Merge pull request #42 from faizalluthfi/patch-1
Browse files Browse the repository at this point in the history
Fix not working example in README
  • Loading branch information
cemremengu authored Feb 21, 2019
2 parents db05812 + b28cbbc commit 142ee3d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ These methods are very similar to their standard jsonwebtoken counterparts.
#### Example
```js
const fastify = require('fastify')()
const jwt = require('fastify-jwt')
const request = require('request')

fastify.register(jwt, {
secret: function (request, reply, callback) {
Expand Down Expand Up @@ -380,20 +382,20 @@ fastify.listen(3000, function (err) {
json: true
}, function (err, response, body) {
if (err) fastify.log.error(err)
fastify.log.info(`JWT token is ${body}`)
fastify.log.info(`JWT token is ${body.token}`)

// verify JWT
request({
method: 'GET',
headers: {
'Content-Type': 'application/json',
authorization: 'Bearer ' + sign.token
authorization: 'Bearer ' + body.token
},
uri: 'http://localhost:' + fastify.server.address().port + '/verify',
json: true
}, function (err, response, body) {
if (err) fastify.log.error(err)
fastify.log.info(`JWT verified. Foo is ${body.bar}`)
fastify.log.info(`JWT verified. Foo is ${body.foo}`)
})
})
})
Expand Down

0 comments on commit 142ee3d

Please sign in to comment.