Reactjs 如何在redux saga调度中等待完整的返回值?

Reactjs 如何在redux saga调度中等待完整的返回值?,reactjs,redux,redux-saga,Reactjs,Redux,Redux Saga,我正在尝试获取myLocation(redux state)变量,该变量将在下一次调度get\u POSTS\u请求中使用。但当我试图放置wait以获得完全返回值时,它显示了错误 index.js const testFunc = () => { const { myLocation} = useSelector(state => state.user); dispatch({ type: MY_LOCATION

我正在尝试获取
myLocation
(redux state)变量,该变量将在下一次调度
get\u POSTS\u请求中使用。但当我试图放置
wait
以获得完全返回值时,它显示了错误

index.js

const testFunc = () => {
const { myLocation} = useSelector(state => state.user);
                dispatch({
                    type: MY_LOCATION_REQUEST,
                    data: {
                        lat: position.coords.latitude,
                        long: position.coords.longitude,
                    },
                });
                dispatch({
                    type: GET_POSTS_REQUEST,
                    data: {
                        dong: myLocation.dong,
                    },
                });
};
sagas/location.js

function getLocationAPI(locationInfo) {
    return axios.post('/location', locationInfo ,{withCredentials: true});
}

function* getLocation(action) {
    try {
        const result = yield call(getLocationAPI, action.data);
        yield put({
            type: GET_LOCATION_SUCCESS,
            data: result.data,
        });
    } catch (e) {
        yield put({
            type: GET_LOCATION_FAILURE,
            error: e,
        });
    }
}

function* watchGetLocation() {
    yield takeLatest(GET_LOCATION_REQUEST, getLocation);
}

export default function* locationSaga() {
    yield all([
        fork(watchGetLocation),
    ]);
}

对于
index.js
中的下一个分派操作,我必须使用
myLocation
。但是,当我试图将
async/await
放入我的
dispatch
时,它不起作用。这有什么解决办法吗?

put方法也有点分派,例如这一部分

收益率看跌期权({
类型:获取位置成功,
数据:result.data,
});
你总是可以看到

调度({
类型:获取位置成功,
数据:result.data,
});
例如,你必须用减速器来“捕捉”这个

函数(状态=初始状态,动作){
开关(动作类型){
案例获取位置成功:
返回Object.assign({},state{
用户:Object.assign({},
state.user,
{
myLocation:action.data
}
]
})
违约:
返回状态
}
}
这将使用api调用返回的数据更新您的状态