I have a problem with HTTP in Angular.
I just want to GET
a JSON
list and show it in the view.
im
Plus what @mlc-mlapis commented, you're mixing lettable operators and the prototype patching method. Use one or the other.
For your case it should be
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import 'rxjs/add/operator/map';
@Injectable()
export class SwPeopleService {
people$ = this.http.get('https://swapi.co/api/people/')
.map((res:any) => res.results);
constructor(private http: HttpClient) {}
}
https://stackblitz.com/edit/angular-http-observables-9nchvz?file=app%2Fsw-people.service.ts