Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

53
Vistas
how to show array received from server in Autocomplete

I'm trying to show the user an array with the names that I get from the server. To allow the user to select the desired item from the list.

If I just write an array, then everything works.

   let liste=  
    [ 
       { label: 'The Shawshank Redemption', year: 1994 },
       { label: 'The Godfather', year: 1972 } 
    ]

 <Autocomplete
              disablePortal
              id="combo-box-demo"
              options={liste}
              onChange={(event , newevent) => {
              setBehoerdeName(newevent) }}
              renderInput={(params) => <TextField {...params} />}
  />

enter image description here

but if I get data from the server, it gives an error although I get an array too.

 let allDates = async function getAllDate() {
        let list = await axios.get("/myWay")
          if (list.data.success) {
            let finalList = list.data.json.map(({name1, ort, plz}) => ({name1, ort, plz}));
            return finalList
          } else {
            return null
          }
      };

 <Autocomplete
              disablePortal
              id="combo-box-demo"
              options={allDates }
              onChange={(event , newevent) => {
              setBehoerdeName(newevent) }}
              renderInput={(params) => <TextField {...params} label="Behörden" />}
   />

i get this error

Uncaught TypeError: options.filter is not a function

I tried to write data to a function and call it in options but the result is the same.

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.