agiledigital / typed-redux-saga

An attempt to bring better TypeScript typing to redux-saga.
MIT License
315 stars 33 forks source link

Typed-redux-saga is not making API call #508

Open hemadriDasari1990 opened 3 years ago

hemadriDasari1990 commented 3 years ago

Redux Action:

export const getUsers = () => {
  return {
    type: GET_USERS_REQUEST,
  };
};

API Request:

export const getUsers = () => {
  return API(GET_USERS, {
    method: "GET",
  });
};

Saga:

function* callGetUsers() {
  try {
    const result = yield* getUsers();
    const { status, data } = result;
    if (status === 200) {
      yield* put({ type: GET_USERS_SUCCESS, payload: data });
    }
  } catch (err) {
    yield* put({
      type: GET_USERS_FAILED,
      payload: err.response.data,
    });
  }
}

export function* watchGetUsers() {
  yield* takeLatest(GET_USERS_REQUEST, callGetUsers);
}

Saga:

yield* fork(watchGetUsers);

After upgrading to typed-redux-saga its not making API call. Am I missing anything here?

jjoekoullas commented 3 years ago

This library, at run-time, is just a passthrough layer. Hence the babel plugin to remove it during build.

Are you sure what you're doing works with redux-saga ?

rpedretti commented 3 years ago

It seems you are missing a call at getUsers

const result = yield* call(getUsers);