when I use console.log(req.body). It says
{
'hero[title]': 'Lorem ipsum <br> Dolor sit amet.',
'hero[description]': 'Dolor sit amet',
uploadon: 'blahblah'
}
but it should look like:
{
hero[title]: 'Lorem ipsum <br> Dolor sit amet.',
hero[description]: 'Dolor sit amet',
uploadon: 'blahblah'
}
do you know the problem? My HTML looks like:
<div class="field">
<label for="hero[title]">Titel</label>
<input name="hero[title]" type="text">
</div>
<div class="field">
<label for="hero[description]">Beschreibung</label>
<textarea name="hero[description]" id="" cols="20" rows="5"></textarea>
</div>
UPDATE:
my Mongoose Model is:
var mongoose = require('mongoose');
var heroSchema = new mongoose.Schema({
title: String,
description: String,
image: String
});
module.exports = mongoose.model("Hero", heroSchema);
And this is my Route:
app.post("/dashboard/hero", function(req, res) {
Hero.create(req.body, function(err, newlyAdded){
if(err){
console.log(err);
} else {
console.log(newlyAdded);
res.redirect("/dashboard/hero");
}
});
});
I want to embed it into an ejs file.