嵌套邮政路由表达

问题描述 投票:0回答:1

我有以下帖子

router.post('/auth',oauth.oAthmiddleware, function(req, res) {
    oauth.auth;
});

它返回访问令牌和其他详细信息

我有另一篇文章

router.post('/refreshToken', function(req, res,next) {
    var username = 'change';
    var password = 'change';
    req.body.username = username;
    req.body.password = password;
   // call '/auth' post
});

在上面我已经改变并调用上面的帖子,并希望从内部帖子返回响应

我怎样才能实现相同的目标

谢谢

node.js express post routing
1个回答
1
投票

你可以这样做:

router.post('/refreshToken', function(req, res,next) {
    req.url = '/auth'
    ...
    req.body.password = password;

    return router._router.handle(req, res, next);
});
© www.soinside.com 2019 - 2024. All rights reserved.