Matt Huntington 9 years ago
parent 7ec27de8c8
commit 032595bb65

@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
@Component({
@ -15,9 +16,16 @@ export class SearchComponent implements OnInit {
) { }
findCharacter(name){
this.http.get('http://swapi.co/api/people/?search=' + name)
.toPromise()
.then(response => console.log(this.results = response.json().results) );
const result = this.http.get('http://swapi.co/api/people/?search=' + name)
.map((response)=>{
return response.json().results;
}).subscribe(
(response)=>{
this.results = response;
}
);
// .toPromise()
// .then(response => console.log(this.results = response.json().results) );
}
ngOnInit() {

Loading…
Cancel
Save