Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

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

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.