Method POST with Handlebars Express Mongodb

Method POST with Handlebars Express Mongodb
0.0 0

#1

I have a problem, my code does not work, it does not take the data I pass it

app.post('/', (req, res) =>{
var photo = new Photo(req.body);

photo.save()
    .then((data)=>{
        res.send(data);

    }).catch((err) => {
        res.status(400).send('Unable to save Photo');
    });
});
<form action="/" method="POST">
            <div class="form-group">
                <label>Title Photo</label>
                <input type="text" class="form-control" name="title" placeholder="Title">
            </div>
             <div class="form-group">
                <label>Photo</label>
                <input type="text" class="form-control" name="image" placeholder="Link Photo">
            </div>

            <button type="submit" class="btn btn-primary">Submit</button>
        </form>

with Postman I can send the data, but no with the form, what is the problem

use Express, Mongodb and Handlebars

please help me


#2

Resolved: I forget to put app.use(bodyParser.urlencoded({ extended: true }));