Ngrx/ effects passing null value on SwitchMap

354 Views Asked by At

The tasks this code is trying to accomplish are these in order

  1. Im trying to listen for an action

  2. take the payload for that action

  3. pass that payload to a database service function

  4. pass the payload to a success reducer action

The data is supposed to be getting saved to Indexeddb in the browser but keeps giving me an error saying its being provided a null value which is not true.

what could be causing a null value to be passed?

@Effect()
public createCampaign$ = this.actions$.pipe(
        ofType(ActionTypes.CREATE_CAMPAIGN),
        map((action: CampaignActions.CreateCampaignAction) => action.payload),
        switchMap((payload) => this.databasService.addCampaign(payload).then(() => Promise.resolve(payload).then(item => item))),
        map((campaign) => (new CampaignActions.CreateCampaignSuccessAction(campaign)))

)
0

There are 0 best solutions below