Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

205
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda