react-native - 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)”。它不等待响应得到结果。请注意,调试器一切正常。
解决方案
推荐阅读
- javascript - ReactJS ES6 箭头函数
- r - 在 R 中计算正确的特征向量以找到特征分解
- django - Postgres 不尊重 Django 在 models.py 中的“on_delete = models.CASCADE”。为什么?
- haskell-stack - 为什么 Haskell Stack 一直在下载相同的东西?
- javascript - Javascript:如何使用reduce函数和concat数组函数将数组数组转换为数组?
- java - 由于不希望的匹配类型,无法覆盖子类中的方法
- javascript - 如何修复javascript中未定义的div?
- php - 在定制器上获取 wordpress 错误“changeset_post_save_failure”
- excel - 如何从函数返回布尔值?
- javascript - 如何更改从数组中删除的元素的属性?