title: TypeError: verifyJsonWebToken is not a function
body: <p>I created two model (I use MongoDB):</p>
  
  <p>User: name, email, password, isBanned, blogPosts[].</p>
  
  <p>BlogPost: title, content, date, author.</p>
  
  <p>with author: {type:ObjectId, ref: 'User'}</p>
  
  <p>I want insert a new blog post with Json Web Token. But I received error: : TypeError: verifyJWT is not a function</p>
  
  <p>Here is my code:</p>
  
  <pre><code>const { verifyJWT } = require('./User')
  const insertBlogPost = async (title, content, tokenKey) =&gt; {
  try {
      //Check Login with tokenKey
      let signedInUser = await verifyJWT(tokenKey) //&lt;-Code not run here
      let newBlogPost = await BlogPost.create({
          title, content,
          date: Date.now(),
          author: signedInUser
      })
      await newBlogPost.save()
      await signedInUser.blogPosts.push(newBlogPost._id)
      await signedInUser.save()
      return newBlogPost
  } catch(error) {        
      throw error
  }}
  module.exports = {
  BlogPost,
  insertBlogPost,
  }
  </code></pre>
  
  <p>Here's verifyJWT from User</p>
  
  <pre><code>const jwt = require('jsonwebtoken')
  const verifyJWT = async (tokenKey) =&gt; {
  try {          
      let decodedJson = await jwt.verify(tokenKey, secretString)
      if(Date.now() / 1000 &gt;  decodedJson.exp) {
          throw "Token timeout, please Login again"
      }
      let foundUser = await User.findById(decodedJson.id)
      if (!foundUser) {
          throw "Can not find user with this token"
      }
      if(foundUser.isBanned === 1) {
          throw "User looked"
      }
      return foundUser
  } catch(error) {
      throw error
  }}
  module.exports = { User, verifyJWT }
  </code></pre>
  
  <p>And here's my router: </p>
  
  <pre><code>router.post('/insertBlogPost', async (req, res) =&gt;{
  let {title, content} = req.body
  //Client must send tokenKey
  let tokenKey = req.headers['x-access-token']
  try {
      let newBlogPost = await insertBlogPost(title, content, tokenKey)
      res.json({
          result: 'ok',
          message: 'Create BlogPost successfully!',
          data: newBlogPost
      })
  } catch(error) {
      res.json({
          result: 'failed',
          message: `${error}`
      })
  }})
  </code></pre>
  
  <p>Github: <a href="https://github.com/vantuan1303/authentication" rel="nofollow noreferrer">https://github.com/vantuan1303/authentication</a></p>