I am using Angular 8 and I am just trying to take the test JSON api from here: https://jsonplaceholder.typicode.com/users and create an array of User objects out of it like this:
export interface User {
name: string;
email: string;
}
I get the data with this:
this.http.get('https://jsonplaceholder.typicode.com/users').subscribe(data => {
this.data = data;
console.log(data);
});
And I am creating my data variable like this:
data: User[] = [];
It doesn't look like the data array is getting set. Do I need to loop through each object on the response and push it to the data array?