我的Express应用程序中有以下路径:
app.post("/users/me/trackers/court_cases", caseValidator, DriversController.court_cases);
我希望能够将信息从第二个中间件casevalidator传递到第三组中间件。第二个中间件当前从一个RESTfulAPI获取JSON数据,我希望在将其发送给用户之前将其传递给最终的路由。
以下是我当前的案例验证器功能:
caseValidator = function(req, res, next){
var case_id = req.body.case_id;
var authOptions = {
method: 'GET',
url: `https://www.courtlistener.com/api/rest/v3/dockets/${case_id}/`,
headers: {
'Authorization' : "myauth"
},
json: true
};
var url = `https://www.courtlistener.com/api/rest/v3/dockets/${case_id}/`
axios(authOptions)
.then((response) => {
console.log("success!")
next();
//// Pass in the JSON data to the next middleware?
})
.catch((error) => {
res.status(400)
.send(error)
});
};