This is my code:
state={
data:{},
place:''
};
handlePlaceChange = async (place) => {
const fetchedData = await fetchData(place);
this.setState({data:fetchedData, place:place});
console.log(data);
}
I am getting fetchedData correctly and when I log it I get the expected object that I am passing from another file. But when i try to console log I get this error when i call the handlePlaceChange function.
Unhandled Rejection (ReferenceError): data is not defined.
But data is defined and it is a state variable!!!!