【发布时间】:2022-01-25 10:46:39
【问题描述】:
我正在使用 NestJs @nestjs/axios HttpModule 向下面的控制器发出 POST 请求:
@Controller('api')
export class ApiController {
constructor(private apiService: ApiService) {}
@Post()
async acceptAllRequest(@Body() data: string) {
return this.apiService.executeAllRequest(data);
}
}
传递给控制器的数据包含我想传递给服务以获取这些 URL 端点并作为单个响应返回的 URL:
@Injectable()
export class ApiService {
constructor(private httpService: HttpService) { }
async executeAllRequest(data: string): Promise<any> {
// convert the data string into json object
// have an array of URL that I want to GET and return as single response
}
}
有什么办法吗?我遇到了使用rxjs forkjoin 但我无法将其作为单个响应返回。我需要你们更多的指导,提前谢谢你们:)
【问题讨论】:
-
您希望所有这些请求顺序发生还是并行发生?
-
如果可以的话,我很想学习顺序和并行方式
标签: typescript axios rxjs nestjs endpoint