Payload error in jsonwebtoken

后端 未结 7 2055
谎友^
谎友^ 2021-02-01 16:50

I am making a web application using nodejs and angular cli I\'m using JWT to authenticate my login function . But when I process it threw this error

Err

相关标签:
7条回答
  • 2021-02-01 17:43
    const token = jwt.sign(user, config.secret, {
          expiresIn: 604800 // 1 week
        });
    

    convert this to

    const token = jwt.sign(user.toJSON(), config.secret, {
          expiresIn: 604800 // 1 week
        });
    

    or you need to console.log(jwt_payload); to find your ID comes under _doc or directly with jwt_payload. because this may change with the versions.

    0 讨论(0)
提交回复
热议问题