I followed a documentation, where they used:
findLessons(): Observable<Lesson[]> {
return this.http.get('http://localhost:3000/api/lessons').pipe(
map(res => res["payload"])
);
}
However this didn't work, I got an undefined.
I came up with this solution, which works fine:
findLessons(): Observable<Lesson[]> {
return this.http.get<Lesson[]>('http://localhost:3000/api/lessons');
}
So why did 1 not work? Are the solutions the same? Which solution is preferred?