Coming from AngularJS to Angular, I'm still trying to wrap my head around rxjs observable.
For example:
User.ts
export class User {
id?:any;
username:string;
password:string;
}
Using <User[]>
myUser(header: any) {
const url = `${this.mainUrl}/my_user`;
return this.http.get<User[]>(url, header).pipe(
map(resp => {
return resp;
})
);
}
Not using <User[]>
myUser(header: any) {
const url = `${this.mainUrl}/my_user`;
return this.http.get(url, header).pipe(
map(resp => {
return resp;
})
);
}
Both methods seem to give the same result. So I'm unsure of the significance of including it or not.
UPDATE:
The data I'm fetching looks nothing like my User.ts
file, but surprisingly no errors are being thrown.
{
"username": "mhqadmin",
"inserted_at": "2019-02-06T07:01:17.024874",
"id": "b491e7c3-da11-40fe-b4b7-8f97fa88a9fd",
"avatar": {
"middlename": "mhqadmin",
"lastname": "headquarters",
"id": "939c2eec-573e-4245-adcc-0771c73f22e4",
"firstname": "marte"
},
"app_role": "mhq-admin",
"app_permission": true
}