How to create angular2 jwt token in angular2
Question: I need to create a jwt in angular2. How do I do that? I am using this for an
api service.

    
    
     jwt_token = ?
    

I can create in python with no issue.


Answer: **Normally tokens are generated on the server-side !! If you are creating them
on client side, its easy to see your password!!**

Anyway, to answer your question:

Best way is to use an existing library, like this one:
<https://www.npmjs.com/package/jsonwebtoken>

`npm install jsonwebtoken --save`

install its typings (if you use TypeScript)

`npm install @types/jsonwebtoken --save`

and use it like this:

    
    
    import * as jwt from 'jsonwebtoken';
    
    let token = jwt.sign({ anyObject: 'here..' }, 'your super secret password!!');
    

