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

118
Visualizações
Filter through JSON data to create a filter based on the location of the job

trying to build a filter for the project I'm building. I want to parse through the JSON I'm getting from the backend API, filter out the job posts based on the "location" and display it.

    useEffect(async () => {
    let condition = await getJobs();
    switch (jobCondition) {
      case 'On-site': condition.filter((condition.jobLocation === 'in_person'));
        break;
      case 'Remote': condition.filter((condition.jobLocation === 'remote'));
        break;
      case 'Hybrid': condition.filter((condition.jobLocation === 'hybrid'));
        break;
      default:
        condition = null;
    }
    if (condition != null) {
      const params = new URLSearchParams({
        jobs: jobFilter || null,
        location: locationFilter || null,
        since: datePosted || null,
        conditions: condition.data,
      });
      history.push({ pathname: '/', search: `${params.toString()}` });
      return;
    }
    const params = new URLSearchParams({
      jobs: jobFilter || null,
      location: locationFilter || null,
      since: null,
      conditions: null,
    });
    history.push({ pathname: '/', search: `${params.toString()}` });
  }, [jobCondition]);

I am clearly doing something wrong here because it does not even change my URL params.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to pass a callback function with one argument as the first parameter and then return a boolean:

condition.filter((con) => con.jobLocation === 'in_person');

By the way, if you want to get the filtered array, you need to reassign condition or assign it to another variable.

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