【发布时间】:2019-06-12 09:37:02
【问题描述】:
我怎样才能返回摩根组合格式字符串
async function sample(){
const res = await axios.get("http://localhost:3000/sample")
const morganFormattedString = morgan('combined', {stream: {write: res => res }})
}
res 将是一个对象,我需要将 res 的对象转换为以下字符串,由摩根内部完成
::ffff:127.0.0.1 - - [18/Jan/2019:04:59:10 +0000] "GET /sample HTTP/1.1" 200 2 "http://localhost/" "Mozilla/5.0 (linux) AppleWebKit /537.36(KHTML,像 Gecko)jsdom/11.12.0"
【问题讨论】: