首页 > 解决方案 > React 本机 redux-saga 请求仅适用于调试器

问题描述

我使用 redux saga 作为中间件,并在这一层调用我的请求。当启用 react-native 调试器请求时完美,但没有调试器,请求似乎不再是异步的。

export function* userLoginSaga(action) {
    yield put(actions.userLoginStart());
    const response = yield GET(`${action.server}`, {
        'Content-Type': 'application/json'
    }, {
        username: action.username,
        password: action.password
    });
    if (response === 503) {
        yield put(actions.serverErrorSuccess(response))
    } else if (response.status === 200) {
        yield put(actions.userLoginSuccess(response.data));
    }
}

没有反应调试器,我得到“未定义不是对象(response.status)”。它不等待响应得到结果。请注意,调试器一切正常。

标签: react-nativedebuggingaxiosredux-sagareact-native-debugger

解决方案


推荐阅读