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

377
Vistas
My filter submission function isn't working as intended. Uncaught TypeError: country.match is not a function

My code isn't working specifically with the country.name.match function not working as intended.

Error code is as follows: App.js:27 Uncaught TypeError: country.name.match is not a function

REST API being used: https://restcountries.com/#api-endpoints-v3-all

Rest of the code if needed:https://github.com/jnatividad-design/FSO/tree/main/part2/countries

const handleFilterSubmit = (event) => {
      console.log(event.target.value)
      setNewFilter(event.target.value)
      const regex = new RegExp ( newFilter, 'i');
      const filteredCountries = () => countries.filter(country => country.name.match(regex));
      setCountries(filteredCountries)
    }

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I figured out what was wrong. The REST API changed the database's structure slightly, adding more specificity to the country and its name. Originally it went country.name instead, it must be country.name.common as the name is another object with properties such as common name, official name, etc.

const handleFilterSubmit = (event) => {
    console.log(event.target.value)
    setNewFilter(event.target.value)
    const regex = new RegExp ( newFilter, 'i');
    const filteredCountries = () => countries.filter(country => country.name.common.match(regex));
    setCountries(filteredCountries)
}

about 4 years ago · Santiago Trujillo 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