Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hemadriDasari1990 opened this issue Apr 6, 2021 · 2 comments
Open

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

hemadriDasari1990 opened this issue Apr 6, 2021 · 2 comments

Comments

@hemadriDasari1990
Copy link

hemadriDasari1990 commented Apr 6, 2021

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
Copy link

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
Copy link

It seems you are missing a call at getUsers

const result = yield* call(getUsers);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants