Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

269
Vistas
How to make other function gets called after first is executed?

I am working on a react app where I am using redux for state management and I have 2 functions to call and I want them to run only after 1st function is executed.

Here's a snippet of whats I am doing:

if (this.props.page_num < this.props.numPages) {
       this.props.fetchCode(params, isFiltered, isSearched).then(() => {
          this.props.setPageNumber(this.props.page_num + 1);
        });
      }

Here I am getting a error stating:

CodeTable.jsx?2468:132 Uncaught TypeError: this.props.fetchCode(...).then is not a function

fetchCode function:

export function* fetchCode(action) {
  try {
    const response = yield call(Services.fetchCode, action.params);
    const { dtoList } = response.data.pagedList;
    const num_pages = response.data.pagedList.numPages;
    const total_records = response.data.pagedList.totalRecords;
    const page_number = response.data.pagedList.pageNumber;
    const postCodeSetsData = dtoList.map(({
    }) => ({
    }));
    yield put(ActionCreator.setCodes(dtoList, num_pages, total_records, postCodeData, page_number, action.isFiltered, action.isSearched));
  } catch (error) {
    sagaException(error);
  }
}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Since you are using redux saga, I believe the most appropriate thing to do is compose another saga.

export function* fetchCodeSetsAndSetPage(action) {
  try {
    yield put (ActionCreator.fetchCodes(...));
    yield put (ActionCreator.setPageNumber(...));
  } catch (error) {
    sagaException(error);
  }
}

And then call that one instead in your component.

Some docs.

about 4 years ago · Juan Pablo Isaza Denunciar

0

make fetchCodeSets function async. You can write promise like then only with an async functions. also use a return statement inside the function. The declaration of the fetchCodeSets function should be like this

const fetchCodeSets = async (params) => {
    //codes here
    return;
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda