I have used to save some data i mongodb database by using this code. When i send to the data to the server using postman successfullt save data in the database. But in server console shows this error message and crash the connection.
router file code
router.post("/timeTableRegistration", function (req, res) {
const newData = req.body
// console.log(newTimeTabl)
const newTimeTable = new classTimeTable(newData)
console.log(newTimeTable)
newTimeTable.save()
.then(result => {
console.log(result)
res.json({ state: true, msg: "Data Inserted Successfully..!" });
})
.catch(error => {
console.log(error)
res.json({ state: false, msg: "Data Inserting Unsuccessfull..!" });
})
res.send("Success");
});
model file code
const classTimeTableSchema = mongoose.Schema({
className: { type: String, require: true },
monday: [{
one: {type: String, require: true},
two: {type: String, require: true},
}],
});