question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

version new jsonwebtoken error

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
kedrovskicommented, Jan 9, 2018

You can try .toObject() -> jwt.sign(doc.toObject(), jwtSecret);

5reactions
NodeJoSecommented, Jan 15, 2018

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found