请求回调callback
直接在dispatch中用callback
dispatch({
type: 'TASK_ADD',
AreaName:this.state.taskDistrict,
CarID:this.state.taskCar,
PointStart:this.state.startStation,
PointEnd:this.state.endStation,
CreatedBy:this.props.account.username,
callback: (res) => {
if (res) {
if(res.Status === 1){
message.success(res.Message+'任务创建成功!');
}else{
message.error('任务创建失败!');
}
console.log(res);// 请求完成后返回的结果
}
}
});
在另外的saga中酱紫写
const data = yield call(request, uri, {
method: 'POST',
body:{
AreaName,
CarID,
PointStart,
PointEnd,
CreatedBy
}
});
console.log(data);
if(callback) callback(data);