How will I able to save in hooks that data from database. Since I need to display the data that I get to dropdown.
Here's my code
const [dataSystem, setdataSystem] = useState([])
const getAllSystems = async() => {
......
}
const getDependentSystems = async() => {
await axios.get('/API' + ID)
.then((response) => {
console.log('LIST OF SYSTEM', response.data)
setdataSystem(response.data)
})
}
Since upon setState
, data is not yet saved to dataSystem
I need to trigger getDeoendetSystems()
twice to display the list on my dropdown.
Result of console.log
LIST OF SYSTEM [{...},{...}]
0: {ID: 1, SYSTEMID: 12 ...},
1: {ID: 2, SYSTEMID: 13 ...}
Thank you