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

194
Vistas
Property 'data' does not exist on type 'void' in Redux action

In trying to execute this action, and while I'm getting the correct data in response on the backend, the data variable is coming back undefined. I'm also getting a TS error saying Property 'data' does not exist on type 'void'

action/churches.js

export const getChurchesBySearch = (searchQuery) => async (dispatch) => {
  try {
    const { data } = await apis.getChurchesBySearch(searchQuery);
    dispatch({ type: "FETCH_BY_SEARCH", payload: data });

  } catch (error) {
    console.log(error.message);
  }
};

Like I mentioned, the correct response is being returned on the backend, but when assigning it to data, data is undefined.

Here are the other files:
apis/churches.js

export const getChurchesBySearch = (searchQuery) => {
  console.log(searchQuery.city);
  axios.get(
    `${url}/search?city=${searchQuery.city}&denom=${searchQuery.denom}`
  );
};

controller/churches.js

export const getChurchesBySearch = async (req, res) => {
  const { city, denom } = req.query;
  try {
    const churches = await Church.find({
      $or: [{ city: city }, { denom: denom }],
    }).sort({ attend: -1 });
    res.status(200).json(churches);
  } catch (error) {
    res.status(404).json({ message: error.message });
  }
};
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You are missing the return statement in the getChurchesBySearch function.

export const getChurchesBySearch = (searchQuery) => {
  console.log(searchQuery.city);
  return axios.get(
    `${url}/search?city=${searchQuery.city}&denom=${searchQuery.denom}`
  );
};
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