I am new to ngrx-6. The effects will listen to action "LOAD_COURSE_DETAILS" and should make a call to service with the course_id (action.payload). But i am getting an error
Property 'toFixed' is missing in type 'Action'.
However, if I do console.log, I could see the data being passed from the component to the effects.
How to pass the parameters to the service?
Thanks in advance.
file: effects
@Effect()
loadCourseDetails$ = this.actions$.pipe(
ofType(CourseActionTypes.LOAD_COURSE_DETAILS),
switchMap((action) => {
console.log('in course effects', action);
return this.courseService.getCourseDetails(action).pipe(
map((data) => new fromCourse.LoadCourseDetailsSuccess(data))
);
})
);
file: actions.ts (my action has payload defined)
export class LoadCourseDetails implements Action {
readonly type = CourseActionTypes.LOAD_COURSE_DETAILS;
constructor(public payload: Number) {}
}
export class LoadCourseDetailsSuccess implements Action {
readonly type = CourseActionTypes.LOAD_COURSE_DETAILS_SUCCESS;
constructor(public payload: ICourse) {}
}
file: component.ts (dispatch action)
loadCourseDetails(id: Number) {
console.log('dispatch course id', id);
this.store.dispatch(new fromCourse.LoadCourseDetails(id));
}
file: service.ts (to be called by effeccts)
getCourseDetails(courseId: Number) {
return this.http.get(`url/${courseId}.json`);
}