Redux-Saga yield call returning back as undefined

The*_*mad 6 javascript saga reactjs redux-saga

Given the following code, I am getting an undefined result back from my yield call. Why is this happening? I am thinking its something with my request function. Not sure why.

In my saga file, this line is coming back undefined: const result = yield call(request, Routes.insightTotals);

I have verified the request is firing off and returning correctly. Could it be my promise chain that is causing this to be undefined?

HTTP Request functions

function request(url, options) {
  return fetch(url, options)
    .then(parseJSON)
    .then(checkStatus);
}

function parseJSON(response) {
  if (response.url === 'https://myurl.com') {
    // This returns as a GZIP body so need to convert to text then parse as JSON
    return response.text()
      .then((res) => {
        const parsed = JSON.parse(res);
        console.log(parsed)
        return parsed;
      }).catch((err) => {
        throw new Error(err);
      });
  }
  return response.json();
}
Run Code Online (Sandbox Code Playgroud)

Saga file

export function* getInsightTotalsRequestHandler() {
  yield takeEvery(actions.GET_INSIGHT_TOTALS, function* getInsightTotalsRequest() {
    try {
      const result = yield call(request, Routes.insightTotals);
      console.log(result); // THIS IS UNDEFINED

      yield put({
        type: actions.GET_INSIGHT_TOTALS_RETURN,
        value: { result },
      });
    } catch (error) {
      yield put({
        type: actions.GET_INSIGHT_TOTALS_RETURN,
        value: { error: error.message ? error.message : '' },
      });
    }
  });
}

export default function* mySaga() {
  yield all([
    fork(other1RequestHandler),
    fork(other2RequestHandler),
    fork(getInsightTotalsRequestHandler),
  ]);
}
Run Code Online (Sandbox Code Playgroud)

Den*_*nge 1

是的。call将返回已解决的承诺值。我最好的猜测是它checkStatus不会返回值(您没有显示它)。