Я впервые в Ngrx Store и хочу использовать его для получения публикаций из моей базы данных.Я могу сделать это для простой публикации, но сейчас я хочу сделать это, но для специального идентификатора
Это мой эффект
@Effect()
getPiinsByProfilesEffect$: Observable<Action> = this.actions$
.pipe(
ofType<featureActions.GetPiinsByProfile>(featureActions.ActionTypes.GET_PIINS_BY_PROFILE),
startWith(new featureActions.GetPiinsByProfile()),
switchMap(action => this.dataService.GetPiinsByProfile(action.id)
.pipe(
map(items => new featureActions.GetPiinsByProfileSuccess(items.results)),
catchError(error =>
observableOf(new featureActions.GetPiinsByProfileFail(error))
)
)
)
);
Это мой сервис
GetPiinsByProfile(id: string): Observable<ListPiinsResponse> {
const limit = '7';
const page = '1';
return this.http.get<ListPiinsResponse>(`${this.baseUrl}/piins/profile/${id}`, {
params: {
limit: limit, page
}
});
}
И это мое действие
export class GetPiinsByProfile implements Action {
readonly type = ActionTypes.GET_PIINS_BY_PROFILE;
constructor(public id: String) { }
}
export class GetPiinsByProfileStart implements Action {
readonly type = ActionTypes.GET_PIINS_BY_PROFILE_START;
}
export class GetPiinsByProfileFail implements Action {
readonly type = ActionTypes.GET_PIINS_BY_PROFILE_FAIL;
constructor(public payload: any) { }
}
export class GetPiinsByProfileSuccess implements Action {
readonly type = ActionTypes.GET_PIINS_BY_PROFILE_SUCCESS;
constructor(public payload: Piins[]) { }
}
Спасибо всем, если вы можете мне помочь:)