Skip to content

Commit d661d4b

Browse files
author
Luke Westby
committed
Update README to reflect addition of async sign
To document changes from #127
1 parent 9414fbc commit d661d4b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ $ npm install jsonwebtoken
1313

1414
# Usage
1515

16-
### jwt.sign(payload, secretOrPrivateKey, options)
16+
### jwt.sign(payload, secretOrPrivateKey, options, [callback])
17+
18+
(Asynchronous) If a callback is supplied, callback is called with the JsonWebToken string
1719

1820
(Synchronous) Returns the JsonWebToken as string
1921

@@ -51,6 +53,11 @@ var token = jwt.sign({ foo: 'bar' }, 'shhhhh');
5153
// sign with RSA SHA256
5254
var cert = fs.readFileSync('private.key'); // get private key
5355
var token = jwt.sign({ foo: 'bar' }, cert, { algorithm: 'RS256'});
56+
57+
// sign asynchronously
58+
jwt.sign({ foo: 'bar' }, cert, { algorithm: 'RS256' }, function(token) {
59+
console.log(token);
60+
});
5461
```
5562

5663
### jwt.verify(token, secretOrPublicKey, [options, callback])

0 commit comments

Comments
 (0)