Linked Questions

Popular Questions

ID from JWT token to id client in

Asked by At

After logging in to my application, the is started and jwt token is generated. In my token is userId.

I would like to assign this id to user id and store them in redis, because at some point I send a socket and I would like to send it to the client only with the id from the token.

const socket = socketIOClient(this.state.endpoint);'new notification');

// this.state.recipientId <- this is id from token JWT

so how do I decode the server-side token jwt and extract the id from it, then assign it to

this is my server.js fragment code:

io.on('connection', socket => {
  socket.on('new notification', () => {
    io.sockets.emit('new notification');

  socket.on('disconnect', () => {
    io.emit('user disconnected');

Related Questions