#nestjs
Вопрос:
Когда пользователь отменяет запрос, срабатывает следующее :
request.on('close', () => {
// console.log('request is closed .....') Here I want to cancel download
})
в случае закрытия я хочу отменить запрос HTTPService.
полный код:
export class FileController {
constructor(private readonly _httpService: HttpService) { }
@Get()
public sampleRequest(@Req() request: Request) {
request.on('close', () => {
// console.log('request is closed .....') Here I want to cancel download
})
this.download()
}
private async download() {
const { data } = await this._httpService.get("URL", { responseType: 'stream' }).toPromise()
//...
}
}
Комментарии:
1.может быть, с помощью axios
cancelToken
github.com/nestjs/nest/issues/4698