Expected "payload" to be a plain object : MEAN Expected "payload" to be a plain object : MEAN angular angular

Expected "payload" to be a plain object : MEAN


The issue is with the way you signed your token

The user you are using is a returned user from mongoose so you will need to use YOUR_USER.toJSON. if the user is not coming from mongoose use JSON.stringify(YOUR_USER) instead

change your code to either

const token = jwt.sign({linkedinUser}, config.secret, {expiresIn: 604800});//if you want to set expiration on the token

OR

const token = jwt.sign(linkedinUser.toJSON(), config.secret);//if you just want to sign the token without setting the expiration


const token=jsonwebtoken.sign(user.toJSON(),config.secret,{expiresIn:30});

add .toJSON() with your object then it will be ok