Angular HTTP GET with TypeScript error http.get(…).map is not a function in [null]

前端 未结 19 2479
时光取名叫无心
时光取名叫无心 2020-11-22 03:36

I have a problem with HTTP in Angular.

I just want to GET a JSON list and show it in the view.

Service class

im         


        
19条回答
  •  情话喂你
    2020-11-22 04:28

    I think that you need to import this:

    import 'rxjs/add/operator/map'
    

    Or more generally this if you want to have more methods for observables. WARNING: This will import all 50+ operators and add them to your application, thus affecting your bundle size and load times.

    import 'rxjs/Rx';
    

    See this issue for more details.

提交回复
热议问题