@Post('signin')
async signIn(@Body() account) {
return this.appService.signIn(account);
}
******************************
{
"success": true,
"message": "use cache",
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c2VyMkB0ZXN0LmNvbSIsImlhdCI6MTYxMDY3NjkyNSwiZXhwIjoxNjEwNzEyOTI1fQ.Tx3a0brtWYD7GQUKYQAq_48biIZCFpqEQsds2-BrINc"
}
-----------------------------------
@Post('signin')
async signIn(@Body() account, @Res() res: Response) {
res.send({
result: this.appService.signIn(account)
})
}
******************************
{
"result": {}
}
결과를 응답으로 보내려고합니다.
하지만 결과는 {} //undefined
내가 res.json()
또는res.send()
쿠키 파서 app.use(cookieParser())
가 이미 완료되었습니다.
당신이 경우 this.appService.login()
입니다 async
전화, 당신은 필요 await
사용하기 전에 응답 res.send()
. 이런 식으로해야합니다
@Post('signin')
async signIn(@Body() account, @Res() res: Response) {
const result = await this.appService.signIn(account);
res.send({
result
});
}
@Res()
Nest가 처리하도록 하는 대신 주입하려는 이유 가 있습니까?
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다