title: TypeError: invNum.next is not a function
body: <p><strong>I have tried this code :</strong></p>
  
  <pre><code>const invNum = require('invoice-number');
  
  router.post('/checkout', async (req, res, next) =&gt; {
  
  if (!req.session.cart) {
      return res.redirect('/pos/');
  }
  
  var saleList = Sale.find().sort({ _id: -1 }).limit(1); // removed (err, data)=&gt;{} to simply view it is working tested already
  var settings = await Setting.find({}); // removed try and catch to simply view it is working tested already
  var ticketNumber;
  
  ticketNumber = !saleList ? invNum.next('0000000') : invNum.next(saleList.ticket_number);
  
  var sale = new Sale({
      ticket_number:ticketNumber,
      cart: req.session.cart,
      created_at: new Date()
  });
  
  sale.save((err, product) =&gt; {
      createReceipt(settings, req.session.cart, "receipts/"+ticketNumber+".pdf");
      req.session.cart = null;
      res.redirect('/pos/');
  });
  
  });
  </code></pre>
  
  <p><strong>I got this error:</strong></p>
  
  <pre><code>TypeError: invNum.next is not a function
  </code></pre>
  
  <p>The problem is with invNum.next().
  invNum.next() is a Node.js module to generate invoice number sequentially installed from npm.</p>
  
  <p><strong>Example:</strong></p>
  
  <pre><code>invNum.next('2017/08/ABC001')
  // =&gt; 2017/08/ABC002
  </code></pre>
  
  <p>I have tried already suggestions from previous stackoverflow posts by trying Promises or await async function in order to get this code to work. Hopefully, you can help or suggest something. Thank you.</p>