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

183
Views
How to filter json api data with condition using react

i'm getting this data from backend api. How can i add filter into json data? For Example if user want keywords which has search volume more than 20000. how can i do that? i appreciate your help in advance

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Great question.

When gathering data from a backend api, in react here's how you would do it:

const [fetchedData, setFetchedData] = React.useState(null);

function fetchData() {
    fetch('http://example.com/movies.json')
  .then(response => response.json())
  .then(data => setFetchedData(data));
};


// loads data initially on page load
React.useEffect(() => {
  fetchData()
  }, [])
  

//use this function to tie to an "onChange" or "onClick" event when submitting the values.
function filterData(inputValue) {
  if(inputValue === "") return;

  
  const filteredData = fetchedData.filter((value) => {
  return value.SEARCH_INDEX_VALUE_HERE >= inputValue
  }
  
  return filteredData;
}



  

You can find a good description from here

This is given that the data returned is an array of objects, and the the SEARCH_INDEX_VALUE_HERE is whatever column key that is provided to the data you're filtering. In your case, it would be the "Search value" field I believe.

about 4 years ago · Juan Pablo Isaza Report

0

You can use filter method of JavaScript like this.

var filteredData = data.filter(function (item)
{
  return item.Search_volume >=20000;
         
}
);
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!