Angular HTTPPOST返回两组数组,如何将这些数组存储在两个不同的可观察数组中

Angular HTTPPOST返回两组数组,如何将这些数组存储在两个不同的可观察数组中,angular,multidimensional-array,Angular,Multidimensional Array,我正在从angular做一个http post,我的api向我发送了两组数组作为回报,现在我想将这些数组分别存储在两个不同的可观察数组中,如何在angular中实现这一点。使用RxJs中的forkJoin,您可以将多个api调用的结果合并到单个请求中,然后在返回时分割为不同的观察值。如果只有一个响应,则只需在公共密钥上拆分数组 这是forkJoin async BuildForkJoinRepriceUI(){ return new Promise<any>((resolve, re

我正在从angular做一个http post,我的api向我发送了两组数组作为回报,现在我想将这些数组分别存储在两个不同的可观察数组中,如何在angular中实现这一点。

使用RxJs中的forkJoin,您可以将多个api调用的结果合并到单个请求中,然后在返回时分割为不同的观察值。如果只有一个响应,则只需在公共密钥上拆分数组

这是forkJoin

async BuildForkJoinRepriceUI(){
return new Promise<any>((resolve, reject)=> {
  const Type1 = this.http.post(this.ApiUrl + "url/1/get", {});
  const Type2 = this.http.post(this.ApiUrl + "url/2/get", {});
  const Type3 = this.http.post(this.ApiUrl + "url/3/get", {});
  const Type4 = this.http.post(this.ApiUrl + "url/4/get", {}); 
  const Type5 = this.http.post(this.ApiUrl + "url/5/get", {}); 
  const Type6 = this.http.post(this.ApiUrl + "url/6/get", {}); 
  const Type7 = this.http.post(this.ApiUrl + "url/7/get", {}); 
  forkJoin([Type1, Type2, Type3, Type4, Type5, Type6, Type7])
  .subscribe((response:any) => {
    let statusCheck = response.filter(status => (status.StatusCode != "Success"));
    if(statusCheck.length){
      reject(false);
    } 
    Type1Observable.next(response[0].Data);
    Type2Observable.next(response[1].Data);
    Type3Observable.next(response[2].Data);
    Type4Observable.next(response[3].Data);
    Type5Observable.next(response[4].Data);
    Type6Observable.next(response[5].Data);
    Type7Observable.next(response[6].Data);
    resolve(true);
  })
})
}
async BuildForkJoinRepriceUI(){
返回新承诺((解决、拒绝)=>{
const Type1=this.http.post(this.ApiUrl+“url/1/get”,{});
const Type2=this.http.post(this.ApiUrl+“url/2/get”,{});
const Type3=this.http.post(this.ApiUrl+“url/3/get”,{});
const Type4=this.http.post(this.ApiUrl+“url/4/get”,{});
const Type5=this.http.post(this.ApiUrl+“url/5/get”,{});
const Type6=this.http.post(this.ApiUrl+“url/6/get”,{});
const Type7=this.http.post(this.ApiUrl+“url/7/get”,{});
forkJoin([Type1、Type2、Type3、Type4、Type5、Type6、Type7])
.订阅((响应:任意)=>{
让statusCheck=response.filter(status=>(status.StatusCode!=“Success”);
if(statusCheck.length){
拒绝(假);
} 
类型1可观察。下一步(响应[0]。数据);
Type2Observable.next(响应[1]。数据);
Type3Observable.next(响应[2]。数据);
Type4Observable.next(响应[3]。数据);
类型5可观察。下一步(响应[4]。数据);
Type6Observable.next(响应[5]。数据);
Type7Observable.next(响应[6]。数据);
决心(正确);
})
})
}

能否添加更多细节和代码?可能的闪电战。API本身在角度上是可观察的,如果您使用的是http客户机,您想分成几个部分吗?你想如何使用它。Http是一维的吗?您想用作多维吗?