Cannot read property collection of null


Getting this error in my slack bot project


Have you created a collection in your mlab (or wherever else you’re hosting your MongoDB) database and set its name in your .env file? See step 3 in


@Gareth Yes.

This is my collection in mlabl:


And my .env file:


Check your database env values. I can reproduce the error when I deliberately set the database name (db in .env) to something incorrect for example.