I'm working on an application which allows you to upload images, and create albums. Everything works fine accept that after an album is created the new album isn't shown in the client until the page is reloaded, and I can't figure out how to solve this.
Below is the route for creating an album. Is it somehow possible to use something else than res.redirect('back') in this case so that the page is reloaded after the route has finished?
Of course I could copy/paste the code from the route for loading the page in the first place, but that would be to much DRY. Maybe I can call the other route from within this route?
route:
app.post('/album', function(req, res){
var newAlbum = new albumModel.Album();
newAlbum.imageName = req.body.albumPicsName;
newAlbum.imageId = req.body.albumPicsId;
newAlbum.title = req.body.albumTitle;
newAlbum.save(function (err) {
if (err) {
console.log(err);
// do something
console.trace();
}
res.redirect('back');
});
});