Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!