我有一個注入了 HttpService 的服務,并使用 @Interval(20000) 啟動請求。在間隔函數中,我使用 this.http.get(...) 向另一臺服務器發出請求,但我沒有看到任何反應,無論是請求還是異常。我只看到控制臺日志“handleInterval”!怎么了? :import {HttpException, HttpService, Injectable} from '@nestjs/common'@Injectable()export class AppService { constructor(private readonly http: HttpService) {} @Interval(20000) handleInterval() { console.log('handleInterval'); let response = this.http.get('192.168.0.162:8081/diag.fhtml', {responseType: 'arraybuffer'}).pipe( map(res => { console.log('received data'); return res.data; }), catchError(e => { console.error(e); throw new HttpException(e.response.data, e.response.status); })); } : :}
@Interval中的nestJs httpService.get請求沒有反應
慕的地8271018
2023-07-29 13:32:44