I have not found any tutorial or information about how to handle post request using JSHTML express.
Can anyone share some example of code that handles post request using JSHTML express, or any further information about JSHTML?
Until now I have only found this: jshtml on github
OK I found the solution. Let's say We have such Restaurant_new.jshtml file
<form method="POST" action="/restaurant/new">
<label>Name</label>
<input type="text" name="name"/>
<label>description</label>
<input type="text" name="desc" />
<label>latitude</label>
<input type="text" name="latitude" />
<label>longitude</label>
<input type="text" name="longitude" />
<input type="submit" value="Submit">
</form>
and we handle this post request by following lines of code in app.js
app.post('/restaurant/new', function(req, res){
restaurantProvider.save({
name: req.param('name'), //dodaj pola
desc: req.param('desc'),
latitude:req.param('latitude'),
longitude:req.param('longitude')
}, function( error, docs) {
res.redirect('/')
});
});
This is all.