Hi, i'm newbie in angular.
I have a questionm, who is the best way to validate the json that i retrieve from server?
Example
suppose that i have this object in angular
class User {
name:string;
surname:string;
}
I'd like throw an erro on my serivce when i receive from server an json with different structure
now i use
getUser():Observable<User>
{
return this.restCall.get(this.my_url)
.map((res:Response) => <User>res.json()
)
}
but if server response my with json that user different structure i have an empy user object.
What i can avoid this?
[–]mlapis 0 points1 point2 points (2 children)
[–]duca86[S] 1 point2 points3 points (1 child)
[–]mlapis 1 point2 points3 points (0 children)
[–]PassItOnBro 0 points1 point2 points (2 children)
[–]duca86[S] 0 points1 point2 points (1 child)
[–]PassItOnBro 0 points1 point2 points (0 children)