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
I had this problem as well, with a returned user from mongoose, just add toJSON()
or toObject()
will fix the issue, but what happens if your user is not always coming from mongoose?
You will get a
user.toJson/user.ToObject is not a function
if you try to do this on a plain object.
If your user is coming from different sources and you don't know if it will be a plain object or not, you can solve it like this:
JSON.parse(JSON.stringify(user));