problem description
react redux, initiates a request using this.props.dispatch (actions.update)
, but does not execute
the environmental background of the problems and what methods you have tried
The interface is a tab switch. When clicked,
this.props.dispatch (actions.fetchALLlevels)
console can print the action, but the request is not sent
related codes
//
import { ofType } from "redux-observable";
import { of } from "rxjs";
import { switchMap, map, catchError } from "rxjs/operators";
import { ajax } from "rxjs/ajax";
import * as actions from "../actions/level";
export const fetchAllLevels = action$ =>
action$.pipe(
ofType(actions.fetchAllLevels),
switchMap(() =>
ajax({
url: "/api/v1/rank/get",
method: "GET",
headers: {
Authorization: localStorage.getItem("token"),
},
}).pipe(
map(data => {
actions.fetchAllLevelsSuccess(data.response)}),
catchError(err => {
toastr.error("");
return of(actions.fetchAllLevelsError(err));
}),
),
),
);