我从(预期的结果是一个对象数组)获得了一个意外的可观察性(比如随机)作为响应res
:
this.api[op.type](op.endpoint,op.body, op.token).pipe(
take(1),
tap(async res=>{
try{
if (res){ //getting Observable here
//do something with res
}
}catch(err){
console.log(err)
}
}),
catchError(async (err)=>{
//more error handling
})
我的api['post']
是这样的:
post(endpoint: string, body: any, token? : string, reqOpts?: any, url_alt?: any) {
this.set_headers(token);
if (!reqOpts) reqOpts = {};
this.headers.append({"Content-Type": "application/json"});
reqOpts.headers = this.headers;
return this.http.post(this.url + endpoint, body, reqOpts).pipe(
timeout(105000),
retry(3),
catchError(async (error)=>{
return throwError(error)
})
);
}
}
我会非常感激任何关于这里哪里出了问题的指导