my code: ``` const jwt = require('jsonwebtoken');...
# prisma-whats-new
r
my code:
Copy code
const jwt = require('jsonwebtoken');

module.exports = (parent, args, ctx, info) => {
  const Authorization = ctx.request.get('Authorization');

  if (Authorization) {
    const token = Authorization.replace('Bearer ', '');
    const { userId } = jwt.verify(token, 'mysecret123');

    return ctx.db.query.user({ where: { id: userId } }, info);
  }

  return null;
};
n
this error message is returned from the
jwt.verify
call.
r
I know, but I dont understand how it can get to the jwt.verify call when Authorization is null. Im trying to get the same functionality as I had with the User query in graphcool, where it either returned null or the currently logged in user.
there is no token yet since there is no logged in user yet
n
There is no way to tell with the code you shared 🙂
r
am I missing something? If
ctx.request.get('Authorization');
returns null, why would it still try to get the token
n
it wouldn't, as far as I can tell
r
when I log Authorization I get:
AUTH HEADER: null
found it