reactive-angular-course icon indicating copy to clipboard operation
reactive-angular-course copied to clipboard

Wrong data types in courses service

Open Poetro opened this issue 2 years ago • 0 comments

On https://github.com/angular-university/reactive-angular-course/blob/8fd38880f715484c309c2381dc9fd1bcd7396f4f/src/app/services/courses.service.ts#L39 it should be

this.http.get<{payload: Course[]}>

so you need to to do additional casting with https://github.com/angular-university/reactive-angular-course/blob/8fd38880f715484c309c2381dc9fd1bcd7396f4f/src/app/services/courses.service.ts#L41 as TypeScript would already know the type of the payload, so you can do

map(res => res.payload)

and it would already have the correct type.

Same goes for all the other HTTP requests.

Poetro avatar Dec 01 '22 11:12 Poetro