solved : Class constructor MongoStore cannot be invoked without 'new'
Solved : Class constructor MongoStore cannot be invoked without 'new'
Above screenshot you can see what is the problem ,
Solution :
follow this code and fix this problem. this type Error is showing because of we using old way to create session and storing in database .
you have to use this for require:
const MongoStore = require('connect-mongo');
and Now use this as store data and create session :
// session for save in cart
app.use(
session({
secret: process.env.COOKIE_KEY, // database url
resave:false,
saveUninitialized:false,
cookie: {maxAge: 1000*60*60*24}, // 24 hours
store : MongoStore.create({
mongoUrl: process.env.dbUrl,
collectionName: 'sessions'
})
})
);

Comments
Post a Comment