Cannot read property collection of null


#1

Getting this error in my slack bot project


#2

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 setup.md.


#3

@Gareth Yes.

This is my collection in mlabl:


#4

And my .env file:


#5

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.