You can specify the type that is being returned, using an interface, class, etc. For example, you can use something like the following:
return this.http.get<Sidebar>('http://localhost:3000/sidebar/edit-sidebar');
As an example, Sidebar might be defined as:
interface Sidebar {
_id: string;
content: string;
}
See Typechecking the response from the Angular docs for further information:
…TypeScript would correctly complain that the Object coming back from HTTP does not have a results property. That’s because while HttpClient parsed the JSON response into an Object, it doesn’t know what shape that object is.