0
I have a problem to create a LOG database of connections, I can get virtually all the data, but the most essential that would be the body of Response, is returning with undefined
, someone would know how to take that amount
Follows code:
const log = require('../utils/log');
function criaLog(req, res){
let now = new Date;
let dados = `Dados da requisicao:
IP: ${req.ip},
Headers: ${JSON.stringify(req.headers)},
Rota: ${req.route.path},
Metodo: ${req.route.stack[0].method},
Data/Hora: ${now.getUTCDate()}/${(now.getMonth() + 1)}/${now.getFullYear()} ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}
Corpo: ${JSON.stringify(req.body)},
Resultado Codigo: ${res.statusCode}, Mensagem: ${res.statusMessage},
Corpo do Resultado: ${JSON.stringify(res.Body)}
`;
log.escreveLog(dados);
}