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} />}
/>
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.