res.redirect does not redirect on expressjs

0

I am nodejs along with expressjs and in submitting a form a request is made on the server, which, after being treated, redirects the page:

...

Post.create(doc, (err, post) => {
    if (err || !post) {
        return res.json({
            status: 'error',
            error: err
        });
    }
    post.save()

    res.redirect('/minha-url')
});
...

But the redirection is not done, although in the devTools panel of Chrome, in the networking tab the redirection appears with status 200 as a request.

I do not understand what the problem might be.

Thanks for any help.

    
asked by anonymous 27.06.2017 / 02:19

1 answer

0

I was doing the post from ajax and not from a form. With this, instead of user res.redirect('route') , I just got the route from the server and used on the client side a

window.location = route;

to redirect.

    
02.07.2017 / 01:37