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

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

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 Denunciar

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