Monday 1 May 2017

Rendering JSON with Marionette

I'm using express router in making a RESTful app, one of the routes is to post from a HTML form:

router.route('/books')

    .post(function (req, res) {

           .....

    })

I'm also using sequelize to validate the data before posting, it's all working fine, if there is no validation error the user will be redirected to a specific page.

if(success) {
    res.redirect('http://localhost:3000/#');
}

if there is an error, I get the errors in a JSON format.

function (err) {
    res.send(err);
}

Sample of the sequlize validation error in JSON format.

Now I want to render those (err) to my Backbone.Marionette view but I feel like I'm in a maze between front-end and back-end, not sure where to start from.



via iseenoob

No comments:

Post a Comment