Describing my method to structure the API Response -
interface MyTest {
property2: string
}
Incorporating Angular 5 Service Code -
getAPI(searchKey: string) {
this.productsAPIUrl =
https://localhost:44331/api/SampleData/WeatherForecasts2";
return this.http.get<MyTest>(this.productsAPIUrl);
}
The Result from my API - https://localhost:44331/api/SampleData/WeatherForecasts2 is
{"property1":"Property1","property2":"Property2","property3":"Property3"}
Utilizing the Angular Service in my Component as follows -
public incrementCounter() {
this.getAutocompleteSuggestions().subscribe((data: MyTest) => {
console.log(data);
});
}
The Query arises after calling the Angular Service, receiving the complete Response. Although I have specified 'MyTest' type with only property2, why do complete results get returned?
What steps are needed to segregate the API Response and how can it be aligned to custom model type MyTest????
Requirement limited to Property2 data. How to effectively map it???