Tuesday 16 May 2017

Node.js post and send data when redirecting

I'm havong trouble sending data from a post to a get when I redirect.

router.post('/search-tutors', isAuthenticated, function(req, res, html) {
    //getData from couchdb view
                findTutor.getTutor(req.body.skill, function(e, o) {
                        if(e)
                                console.log(e);
                        else {
                                console.log(o);
        //send data to /find-tutor ?
                                res.redirect('/find-tutor');
                        }
                });
        }); 



router.get('/find-tutor',isAuthenticated, function(req, res, html) {
                res.render('templates/find-tutor.jade', {
                        basedir: './views/templates',
                        title: 'Find tutor',
      data: //data from previous post
                })
        });

Can you help me ? THx a lot !



via Nicolas Sailly

No comments:

Post a Comment