title: TypeError: cb is not a function
body: <p>I'm stuck. I keep getting the same cb is not a function error. Here's my error:</p>
  
  <p>TypeError: cb is not a function</p>
  
  <p>I just started learning javascript a few days ago, so I'm very new. I'm simply watching youtube videos that do what I need done for my application and I write what they write. So far it's been going well, had a few problems that I managed to fix on my own. But this one I can't figure out. So a little help would be very much appreciated.</p>
  
  <pre><code>var isValidPassword = function(data,cb) {
      db.users.find({username:data.username,password:data.password},function(err,res) {
          if (res.length &gt; 0) {
             return cb(true);
          } else {
             return cb(false);
          }
      });
  }
  
  var isUsernameTaken = function(data,cb) {
      db.users.find({username:data.username},function(err,res) {
          if (res.length &gt; 0) {
             return cb(true);
          } else {
             return cb(false);
          }
      });
  }
  
  var addUser = function(data,cb) {
      db.users.insert({username:data.username,password:data.password},function(err) {
         return cb();
      });
  }
  
  io.on('connection', (sock) =&gt; {
      sock.id = Math.random();
      SOCKET_LIST[sock.id] = sock;
      console.log('someone connected');
  
      sock.on('signIn', function(data) {
          if (isValidPassword(data)) {
              sock.emit('signInResponse', {success:true});
          } else {
              sock.emit('signInResponse', {success:false});
          }
  
      });
  
  sock.on('signUp', function(data) {
      if (isUsernameTaken(data)) {
          sock.emit('signUpResponse', {success:false});
      } else {
          addUser(data);
          sock.emit('signUpResponse', {success:true});
      }
  
  });
  </code></pre>
  
  <p>});</p>
  
  <p>I keep getting this error:</p>
  
  <pre><code>TypeError: cb is not a function
      at C:\Users\user\Desktop\Mekkie\mekkie\testlogin.js:32:19
      at C:\Users\user\Desktop\Mekkie\mekkie\node_modules\mongojs\lib\cursor.js:73:24
      at AsyncResource.runInAsyncScope (async_hooks.js:188:21)
      at runInAsyncScope (C:\Users\user\Desktop\Mekkie\mekkie\node_modules\mongojs\lib\cursor.js:195:16)
      at C:\Users\user\Desktop\Mekkie\mekkie\node_modules\mongojs\lib\cursor.js:205:5
      at handleCallback (C:\Users\user\Desktop\Mekkie\mekkie\node_modules\mongojs\node_modules\mongodb\lib\utils.js:120:56)
      at C:\Users\user\Desktop\Mekkie\mekkie\node_modules\mongojs\node_modules\mongodb\lib\cursor.js:683:5
      at handleCallback (C:\Users\user\Desktop\Mekkie\mekkie\node_modules\mongojs\node_modules\mongodb-core\lib\cursor.js:171:5)
      at setCursorNotified (C:\Users\user\Desktop\Mekkie\mekkie\node_modules\mongojs\node_modules\mongodb-core\lib\cursor.js:515:3)
      at C:\Users\user\Desktop\Mekkie\mekkie\node_modules\mongojs\node_modules\mongodb-core\lib\cursor.js:599:16
  </code></pre>