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粉3443557152023-09-16 14:28:02
I think this line
module.export = connectToMongo;
should be
module.exports = connectToMongo;