angular observable http call map response to interface

I have a function that calls a rest api like this:

I have a function that calls a rest api like this:

getProducts(category: string): Observable<IProduct[]> {
    let url = `/rest/getproducts?category=${category}`;
    return this._http.get<IProduct[]>(url);
  }

The response from the service looks like this:

[
  {
    "ProductId": 1,
    "CategoryType": "XC",
    "Name": "Prod A"
  },
  {
    "ProductId": 2,
    "CategoryType": "XY",
    "Name": "Prod B"
  },
]

My model looks like this:

export interface IProduct {
    id: string;
    type: string;
    name: string;
}

Is there a way to map the response to my model in an easy way? Should I use the map function? I know I could change the model to suite the response, but I would rather like to squeeze the response into my model (the example is simplified).

Angular JS Development Company

If you’re finding AngularJS Development Company for consultation or Development, your search ends here at Data EximIT 

🔗 Click here to know more: AngularJS Development




What is AngularJs 4? Is it a good time to learn Angular Js 4?

Angular 4 is an open-source JS framework used for creating Mobile and web applications in HTML and TypeScript(which is a subset of JS). We can also say that Angular 4 is a significantly modified version of Angular 2. The change what Angular team brought was the TypeScript.

Angular 4 is an open-source JS framework used for creating Mobile and web applications in HTML and TypeScript(which is a subset of JS). We can also say that Angular 4 is a significantly modified version of Angular 2. The change what Angular team brought was the TypeScript.