I'm sorry about my confusing title but I basically have an Interface
export interface Tutor {
name: string;
rating: number;
personalInfo: string;
}
And a function that Is getting a list of so-called Tutors from my back-end:
public loadTutors() {
const url = 'http://localhost:8080/loadTutors';
this.http.get<Tutor[]>(url).pipe(map(tutor =>
tutor.forEach(tut => this.tutors.push(tut))))
.subscribe();
console.log(this.tutors);
}
There are more fields in entity model of my back-end project then in Tutor Interface and adding a new Entity for only this specific request doesn't seem like a good scalable solution. After the function I get something like this:
Array(2)
0:
username: "Some Username"
email: null
name: null
password: "$2a$11$T44uetsjh1HxLu/ilsTiMODu.aoKLf8/zo3WPM/FUjeMXZRkpDz1S"
balance: 0
personalInfo: "Some personal Info"
rating: 0
userRoles: [{…}]
__proto__: Object
...
What would be the best practice of iterating through response fields or fitting the response to the Tutor Interface?
Thank you for your time and responses in advanced and I hope that you'll have a nice day!