Created
April 13, 2017 13:48
-
-
Save SergioLarios/4818c83738cbc1b9a6f79201c35bbb61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { sign, verify } from "jsonwebtoken"; | |
class Testpromise { | |
create(object: any):Promise<boolean> { | |
return new Promise(next => next(true)); | |
} | |
} | |
let test:Testpromise = new Testpromise(); | |
test.create({}).then((success) => { | |
console.log("-->", success); | |
}); | |
let payload:Object = { username: 'test' }; | |
sign(payload, 'secretKey', { expiresIn: '3d' }, (err: any, token: any) =>{ | |
console.log(err, token); | |
verify(token, 'secretKey', (err: any, decoded: any) =>{ | |
console.log(err, decoded.username); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment