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

Popular posts from this blog

how to get 1,000 rupya by Bihar government immediately || in Hindi||covid19

How to get 1000 rupya by Bihar VIP party in Hindi

10th class scholarship10 बिहार के छात्रों के लिए