Angular - HttpClient: Map Get method object result to array property

后端 未结 5 620
忘了有多久
忘了有多久 2021-02-04 06:19

I am calling an API that returns a JSON Object. I need just the value of the array to map to a Observable . If I call api that just returns the array my service call works.

5条回答
  •  一个人的身影
    2021-02-04 06:46

    Latest HttpClient which should be used instead of http has no map method. You should first import it by import { map } from 'rxjs/operators'; Then you should use it this way:

    this.http.get(`${someURL}/shows`).pipe(
            map(res => res['shows'])
        )
    

提交回复
热议问题