I am getting multiple objects from server and i am returning that i want to store them as Array of objects in angular 4 .
service :
search(term: string): Observable<Array<Object>> {
let apiURL =`${this.apiRoot}?search=${term}`;
return this.http.get(apiURL)
.map(res => {
return res.json().results.map(items => {
items.name,
items.population
});
});
}
}
Component :
private results : [Object];
this.searchField = new FormControl();
this.searchField.valueChanges
.debounceTime(400)
.distinctUntilChanged()
.switchMap(term => this.myservice.search(term))
.subscribe(value => console.log(value) );
}
}
I am not getting Array of Objects ?