I used the componentDidMount method as async and made some operations, but the system returned to me the state of the first entry instead of working async.
async componentDidMount() {
await this.getCityList();
console.log(this.state.cities)
await this.currentLocation();
}
At this point the console log turns empty. however, when I normally check, data input is observed, but comes after a while. The same applies to the currentloc method. These methods draw some data from the database.
and city function:
getCityList() {
let link = "http://..../Cities";
fetch(link)
.then(response => response.json())
.then(res => {
this.setState({
cities: res,
})
})
.catch(error => console.warn(":::::::::", error));
}