title: MongoDB Node.js TypeError: Cannot read property 'db' of null
body: <p>I'm making a DB for my project, but in this code:</p>
  
  <pre><code>function getallvideos(callback) {
    MongoClient.connect(url, function(err, client) {
      const db = client.db("cathub")
      db.collection("videos", function(err, collection) {
        collection.find().toArray(function(err, res) {
          callback(res)
        })
      })
      db.close()
    })
  }
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'db' of null</p>
  </blockquote>