I am leveraging HttpClient instead of Http for my service call along with Observable which works well. However, I want to map some of the custom properties. Is that something we can fetch and map?
To give you background: I have One service: this calls web api and pack the result in Observable> like>
getArticles(): Observable<Array<ArticleViewModel>> {
return this.httpClient.get<Array<ArticleViewModel>>(this.url.articleurl);
}
next I have component, which calls this server like:
getArticles(): void {
this.articles = this.articleService.getArticles();
}
finally, I have ViewModel which has all the properties of Article ViewModel.
However, the Web Api returns much more properties than I have in my Angular View Model. Moreover, some of the properties has different name than I have in Angular VM. So, I want to map those with correct properties and further I want to use some of the web api properties just to validate before setting up Angular Property value.
But the same time, I don't want to use http (@angular/http
). I want to continue with latest httpclient (@angular/common/http
).
But that service directly map the result with my angular view model.
so is that something we can create view model meaningfully by checking all the web api properties?