redux-saga - 当 promise 解决时,redux-saga 调用不会产生。这里会发生什么?
问题描述
这是我的代码:
console.log('call will be made');
const { Status, CallbackUrl } = yield call(fetchUrl, getSsoEndpointUrl(), options);
console.log('call has yielded');
function fetchUrl(url: string, options: RequestInit) {
return fetch(url, options)
.then((response) => {
return response.json();
})
.then((data: SsoServerReponse) => {
console.log('promise resolves', data.data);
return data.data;
});
}
我得到以下日志输出:
sagas.ts call will be made
sagas.ts promise resolves {Status: 200, CallbackUrl: "..."}
我不明白这里可能出了什么问题。fetchUrl
承诺解决。为什么console.log('call has yielded')
永远不会发生?
解决方案
问题是我在代码的其他地方有以下几行:
yield take(LOCATION_CHANGE);
yield cancel(ssoSignInWatcher);
换句话说,通过阅读我的问题几乎不可能猜到这个问题。我正在结束这个问题。
推荐阅读
- smarty - Smarty 中的 Foreach
- reactjs - 如何在酶和玩笑中使用模拟功能模拟点击事件?
- wordpress - Wordpress 在删除帖子后引用了错误的链接
- react-native - 尝试获取导航参考时反应本机博览会崩溃
- python - 如何全局使用python中的对象?
- javascript - 如何使组件仅对少数响应的用户可见/可用?
- c# - .Net Core 2 EF核心连接字符串问题
- php - ErrorException:试图获取非对象的属性“id”
- javascript - 改变滑动菜单的滑动方向和位置
- angular - 在 Angular6 中使用 ng2-toastr {ToastsManager}