我有一个如下所示的 odata 结果
我想从这里获取“值”,在此之前我想将@odata.count保存在localStorage中,或者可能只是记录它。
getAllBankAccounts(url: string): Observable<BankAccount[]> {
return this.http.get(url).pipe(map((res) => res['value']));
}
如何返回“value”属性中的 observale 数组,但在此之前存储“@odata.count”。 ?
最佳答案
您可以使用tap挖掘可观察值的值(value)。
getAllBankAccounts(url: string): Observable<BankAccount[]> {
return this.http.get(url).pipe(tap(res=>console.log(res['@odata.count'])),map((res) => res['value']));
}
关于angular - 如何在map之前在rxjs中保存值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61965788/