【发布时间】:2020-02-04 09:28:12
【问题描述】:
以下是我在 redux 方面的 reducer。
我想在得到服务器端的响应后拨打一个axios 电话。
这里有两个函数,其中包含getList 和updateList。所以我的要求是当updateListSuccess响应得到时,我需要调用函数getDetails。
在得到用粗体字母或星号表示的响应后如何调用getDetails函数。
export function updateList(_id, data) {
return dispatch => {
dispatch(updateListLoading());
axios
.put(`/api/dataList/${_id}`, data)
.then(res => {
**dispatch(updateListSuccess(res.data));**
})
.catch(err => {
if (err.response && err.response.data) {
dispatch(updateListFail(err.response.data));
}
});
};
}
export function getDetails() {
return dispatch => {
dispatch(getDetailsLoading());
axios
.get("/api/getDetails")
.then(res => {
dispatch(getSuccessResponse(res.data));
})
.catch(err => {
if (err.response && err.response.data) {
dispatch(getLoadfail(err.response.data));
}
});
};
}
谢谢。
【问题讨论】:
标签: reactjs redux redux-thunk