there are many APIs in model that can only be called after login. It is normal for code to return 2000.When
returns 20020, the session expires. At this time, I want to jump back to the login page. This is how I handled it
*fetchShopSaleList({ payload }, { call, put }) {
let res = yield call(qryShopSaleGroup, payload);
if(res.code === 200) {
yield put({
type: "save",
payload: {
shopCardList: res.data,
},
});
} else if (res.code === 20020) {
yield put(routerRedux.push("/user/cloudlogin"));
}
},
*fetchShopSaleInfo({ payload }, { call, put }) {
let res = yield call(qryShopSaleGroup, payload);
if(res.code === 200) {
yield put({
type: "save",
payload: {
shopSaleInfoList: res.data,
},
});
} else if (res.code === 20020) {
yield put(routerRedux.push("/user/cloudlogin"));
}
},
in each method, determine whether the returned code is equal to 20020, and if so, jump to the login page.
I have to write one more judgment under each interface, which doesn"t feel good.
is there any way to deal with it in a unified way?