簡體   English   中英

如何使用 pipe 和過濾器使用 angular HttpClient 服務從 json 文件中獲取數據?

[英]How to fetch data from json file using angular HttpClient service using pipe and filter?

在此處輸入圖像描述

以上是json數據的結構。

在此處輸入圖像描述

以上是我為獲取特定用戶的“AllTranscations”數組而編寫的代碼。

有人可以幫我解決我在 getAllTansactionsByUser() 中錯誤的邏輯嗎?

像這樣:

return this.http.get<Transaction[]>(this.userDataURL).pipe(
  map(data => data
    .filter(transaction => transaction.UID === UID)
    .map(transaction => transaction.AllTransactions)
);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM