Just started with angular(version 7). I try to get a response from json-placeholder, an array of todos. That should return an array but when i console.log(typeof rsp) it shows an object.
Observable:
url: string = 'https://jsonplaceholder.typicode.com/todos';
getHomeTodos() {
return this.http.get(this.url);
}
Observer in my component:
ngOnInit() {
this.todosService.getHomeTodos()
.subscribe((rsp) => {
this.homeTodos = rsp;
});
}
Any ideas why the type of rsp is 'Object' but on the json-placeholder it shows it returns an array? Thanks.
console.log(typeof []);: you'll get object too. An array is an object.(rsp: any[])