가 내가 보낸 후 응답을 감사 싶습니다 명시 적 사용하고 보내 그것을익스프레스 응답 본문 후
var app = express();
app.use(audit.auditRequest); // working fine
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(expressValidator({
customValidators: validations.customValidators,
customSanitizers: sanitizers.customSanitizers
}));
app.use(auth.authenticate);
app.use('/myPath', myPathHandler);
app.use(errorHandler.handleErrors);
**app.use(audit.auditResponse);**
의 ErrorHandler 예를 들어, 다음과 같습니다
...
res.status(500).send({ message : "abc", code: 5010, description : "def" });
next(); // call audit middleware
하고 감사 미들웨어 다음과 같이 표시됩니다.
...
auditModule.auditResponse = function auditResponse(req, res, next) {
auditLogger.info('Response', res.body);
// but res.body is undefined
};
...
이유가 무엇입니까?
당신은'req.body'을 원하셨습니까? – Iceman
아니요, 사용자에게 보내는 응답을 기록해야합니다. –
여기에 전체 코드를 입력하십시오. – Iceman