version new jsonwebtoken error
See original GitHub issueI use the new version with the error occurred “jsonwebtoken”: “^8.0.1”,.
I use the old version the bug has been removed “jsonwebtoken”: “^7.4.3”.
MESSAGE ERROR ==>
var token;
try {
token = jwt.sign(doc, jwtSecret, { expiresIn: '10h' });
} catch (error) {
console.log("ERROR==================>"+ JSON.stringify(error));
}
events.js:160 throw er; // Unhandled ‘error’ event ^
Error: Expected object at validate (E:\App\code\node_modules\jsonwebtoken\sign.js:34:11) at Object.module.exports [as sign] (E:\App\code\node_modules\jsonwebtoken\sign.js💯7) at E:\App\code\dist\app.js:402:37 at Query.<anonymous> (E:\App\code\node_modules\mongoose\lib\model.js:3841:16) at E:\App\code\node_modules\kareem\index.js:273:21 at E:\App\code\node_modules\kareem\index.js:131:16 at _combinedTickCallback (internal/process/next_tick.js:73:7) at process._tickDomainCallback (internal/process/next_tick.js:128:9)
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Decode JWT runtime error troubleshooting | Apigee Edge
This error occurs if the JSON Web Token (JWT) specified in the <Source> element of the Decode JWT policy is malformed, invalid or...
Read more >Decode JWT runtime error troubleshooting | Apigee X
This error occurs if the JSON Web Token (JWT) specified in the <Source> element of the Decode JWT policy is malformed, invalid or...
Read more >jsonwebtoken - npm
JSON Web Token implementation (symmetric and asymmetric). Latest version: 9.0.0, last published: 8 days ago. Start using jsonwebtoken in ...
Read more >jsonwebtoken::errors::Error - Rust - Docs.rs
API documentation for the Rust `Error` struct in crate `jsonwebtoken`. ... EK: Into<ErrorKind>, [−]. Extends the error chain with a new entry.
Read more >NodeJS can't get error message from jsonwebtoken
you can include the token as well...might be easier to assist with it... – Mosd. Aug 19, 2021 at 6:57 · Thx, I...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can try
.toObject()
->jwt.sign(doc.toObject(), jwtSecret);
@kedrovski or @UNADYNE solution works fine but i suggest you to use:
JSON.parse(JSON.stringify(doc))
if your doc object comes from diferent sources, for example:You could have to pass diferent “doc” objects, one returned from mongoose and another defined by you like this:
doc = { name: 'foo', description: 'bar' }
If you use
.toJSON()
or.toObject()
You will get a “doc.toObject/doc.toJSON is not a function” error with the doc you defined manually.