通过Angular中的ID从JSON文件中检索数据。TypeError: items.find不是函数

尝试从JSON文件中通过id获取数据,但在控制台中出现错误

 TypeError: items.find is not a function

{
"product" :{
       "data" : [
           { "itemID" : "1" , "name" : "pen" , "qty" : "8" }`,
           { "itemID" : "2" , "name" : "notepad" , "qty" : "5" } 
  ]

} }

我正在使用的函数,其中TypeError: items.find不是控制台中的函数

       getitems(itemID: string) {
           return this.http.get<Array<Fruits>>('assets/localjson.json')
           .pipe(
           map((items: Array<any>) => {
            return items.find((item: Fruits) => {
             return item.itemID=== itemID;

         });
         })
          );
         }
          office.ts
            export class officeitems {
               itemID: string;
               name: string;
               qty: string;

            }

转载请注明出处:http://www.lsql.net/article/20230521/1511546.html