I have a method on a service where I need to get some data from the redux store and use it in an http request, but I keep getting errors or the http request is not executed, here' what I'm trying:
class SettingService {
updateSettings({ settings }) {
return this.store.select(s => s.settings).map((state: any) => {
const { id } = state.data;
return this.http.put('route/' + id, { settings }).pipe(map((response: any) => {
const { data } = response;
this.store.dispatch(new GetSettingsSuccess({ data }));
return data;
})).pipe(catchError(this.errorHandlerService.handleError));
});
}
}
Errors I'm getting are things like
Property 'map' does not exist on type 'Observable'
the way I'm using this is importing the service into a component, then:
this.settingService.updateSettings({ settings }).subscribe();
the method is called, but for some reason the http request doesn't happen. Am I supposed to subscribe to the http request too? or should I use pipe instead of map and give it multiple operators instead?