If you want to ensure the correct type, consider creating a specific interface and using that instead of relying on any
. You can also choose to stick with your current method if it suits your needs.
Specific Interface:
interface SpecificType {
data: Info[];
details: Description;
}
Implementation with Interface:
fetchData(): Observable<SpecificType> {
return this.http.get<SpecificType>(url).pipe(map((response) => response));
}
Original Implementation:
fetchData(): Observable<{
data: Info[];
details: Description;
}> {
return this.http
.get<{
data: Info[];
details: Description;
}>(url)
.pipe(map((response) => response));
}