TypeError: connectToMongo is not a function
P粉428986744
P粉428986744 2023-09-15 17:04:19
0
1
746

Type error: connectToMongo is not a function

My code (Index.js)

const connectToMongo = require('./db')
connectToMongo();

My code (db.js)

const mongoose = require('mongoose');
const mongoURI = "mongodb://localhost:27017"

const connectToMongo = ()=> {
    mongoose.connect(mongoURI,()=>{
        console.log("Connected to mongo successfully")
    })
}

module.export = connectToMongo;

Can anyone help?

P粉428986744
P粉428986744

reply all(1)
P粉344355715

I think this line

module.export = connectToMongo;

should be

module.exports = connectToMongo;
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template