当promise解析时,redux-saga调用不会产生。这可能是怎么回事?

时间:2018-12-04 08:36:45

标签: 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')永远不会发生?

1 个答案:

答案 0 :(得分:0)

问题是我在代码的其他地方有以下几行:

yield take(LOCATION_CHANGE);
yield cancel(ssoSignInWatcher);

换句话说,通过阅读我的问题很难猜出这个问题。我正在解决问题。