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

121
Vistas
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 Respuestas
Responde la pregunta

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