I'm trying to create a basic CRUD app and want to extract information from a form that includes a dropdown menu. I am using body-parser to take in user data and then want to show the data on a new page (however, for now I am just console.log-ing the data to ensure everything is coming through).HTML:
router.post("/", isLoggedIn, function(req,res){ const listing = new Property({ propertyUser: { id: req.user._id, name: req.user.username }, propertyDescription: req.body.propertyDescription, propertyBeds: req.body.propertyBeds, propertyImage: req.body.propertyImage, propertyLocation: req.body.propertyLocation, dropdown: req.body.selectPicker }); console.log(req.body); //JUST TRYING TO LOG THE DATA FOR NOW const propertySchema = { propertyUser: { id: { type: mongoose.Schema.Types.ObjectId, ref: "User" }, name: String }, propertyDescription: String, propertyBeds: Number, propertyImage: String, propertyLocation: String, dropdown: String, comments: [ { //Associate comments with the property type: mongoose.Schema.Types.ObjectId, ref: "Comment" } ] }; When I console.log(listing) I get the listing in the terminal but the "dropdown" doesn't show at all, whereas when I console.log(req.body) I get all the data from the form, including "dropdown" data.
Submitted November 18, 2019 at 04:24PM by robint88
No comments:
Post a Comment