Rumah > Soal Jawab > teks badan
Ralat jenis: connectToMongo bukan fungsi
Kod saya (Index.js)
const connectToMongo = require('./db') connectToMongo();
Kod saya (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;
Ada sesiapa boleh tolong?
P粉3443557152023-09-16 14:28:02
Saya rasa baris ini
module.export = connectToMongo;
sepatutnya
module.exports = connectToMongo;