Updated example code
This commit is contained in:
10
README.md
10
README.md
@@ -31,6 +31,10 @@ async () => {
|
||||
// Verifing token
|
||||
const isValid = await jwt.verify(token, 'secret')
|
||||
|
||||
// Check for validity
|
||||
if (!isValid)
|
||||
return
|
||||
|
||||
// Decoding token
|
||||
const payload = jwt.decode(token)
|
||||
}
|
||||
@@ -53,6 +57,10 @@ async () => {
|
||||
// Verifing token
|
||||
const isValid = await jwt.verify(token, 'secret') // false
|
||||
|
||||
// Check for validity
|
||||
if (!isValid)
|
||||
return
|
||||
|
||||
// Decoding token
|
||||
const payload = jwt.decode(token) // { name: 'John Doe', email: 'john.doe@gmail.com', ... }
|
||||
}
|
||||
@@ -103,4 +111,4 @@ Argument | Type | Satus | Default | Description
|
||||
`token` | `string` | required | - | The token string generated by `jwt.sign()`.
|
||||
|
||||
#### `return`
|
||||
Returns payload `object`.
|
||||
Returns payload `object`.
|
||||
|
||||
Reference in New Issue
Block a user