Hi so i have an array of objects that look like this
[{
"id": 0,
"name": "Del Vecchios | Italian Food | Asheville, NC",
"domain": "delvecchiositalian.com",
"email": "[email protected]",
"phone": "828-258-7222",
},
{
"id": 1,
"name": "DeRango's Pizza Palace | Italian Restaurant | Racine, WI",
"domain": "derangos.com",
"email": "[email protected]",
"phone": "262-639-4112",
},
{
"id": 2,
"name": "Michigan's Premier Flooring Installation Services | D.E. McNabb",
"domain": "demcnabb.com",
"email": "no email",
"phone": "(248) 587-1500",
},
}]
And i want to store it in my mongo database but i dont know how to make the schema, my actual schema looks like this
const mongoose = require("mongoose");
const infoSchema = new mongoose.Schema(
{
info: {
type: String,
trim: true,
required: true,
maxlength: 3200
}
},
{ timestamps: true }
);
module.exports = mongoose.model("ScrapedInfo", infoSchema);
and this is the controller for saving the data
router.post('/stored', (req, res) => {
const info = new ScrapedInfo(req.body)
info.save((err) => {
if (err) {
console.log(err+"error")
}
else{
console.log('saved')
}
});
});
Dunno if i am making a mistake in the controller, seems fine to me, but i every time i run the button for the controller, i have the rror ValidationError: info Path info is required
console.log(req.body), what's the output.