When I dispatching my action in my component this updateTour effect should be triggered. but this error appears in my browser console core.js:5847 ERROR TypeError: Cannot read property 'pipe' of null at SwitchMapSubscriber.project (updatetour.effects.ts:87)
requestHandlerService.invoke(request).pipe
causing the error. can someone explain what's wrong here
updataTour$ = createEffect(() =>
this.actions$.pipe(
ofType(TourproviderAction.updateTourprovider),
switchMap((action) => {
const data = action.tourProvider;
const parameters: any = { tourProviderId: '1' };
const queryParams = new HttpParams({
fromObject: parameters
})
const options = {
params: queryParams,
headers: {
'Content-Type': 'application/json',
'Authorization': 'a5sfjdksfjksfe2f4af3673ce1a'
}
};
const request = new ServiceRequest
(environment.urls.tourProvider, 'POST', formData, options);
return this.requestHandlerService.invoke(request).pipe(
map((updateResponce) => {
const responceData = JSON.stringify(updateResponce)
return TourproviderAction.updateTourproviderSuccess({ responce: responceData });
}),
catchError(err => {
const errorMessage = JSON.stringify(err);
return of(TourproviderAction.updateTourproviderFail({ errorMessage }))
})
);
})
)
);
The error means that this line
this.requestHandlerService.invoke(request)
is returning null and cannot call pipe function. Make sure that you return Observable from invoke method so that you can pipe the reponses.