I have developed a function that retrieves new data from a service file each time it is called.
Here is how the function looks:
onCarChange() {
this.carService.getCarData(this.selectedCar).subscribe(
async (response: CarData) => {
if (response?.data === null) {
this.showCarData = false;
} else {
this.showCarData = true;
}
},
(error) => {
this.showCarData = false
console.error(error);
}
};
The contents of my service.ts file are as follows:
getCarData(carId: string) {
return this.http.get(API.carData.get(carId));
}
The function is functioning perfectly and as expected, so there are no issues on that front. However, I am currently in the process of cleaning up my code and I have noticed that the subscribe method is crossed out and marked as deprecated. Can anyone provide guidance on removing this deprecation warning? Do I need to refactor the function? If so, what would be the revised version?