0

Can't understand why it doesnt work when the function is defined as a async function.

my code

Help is very appreciated :))

2
  • first of all, past your code here. second, what isnt working? what are you receiving? Commented Sep 27, 2020 at 16:19
  • Posted my code as a image :)) But iit instaly crashes because it says I used await in none async function, but I defined the function as async Commented Sep 27, 2020 at 16:22

1 Answer 1

1

You are using await keyword in a function that isn't async. It is the callback for jwt.verify():

jwt.verify(token, config.get('jwtSecret'), async (error, decoded) => {
  // ... code omitted
  const user = await User.findOne({id});
  // ... code omitted
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.