I'm developing a webApp using React, I'm having issues accessing data inside a javascript Object, here is the code:
const user_position = System.prototype.getUserPosition();
console.log({user_position:user_position,latitude:user_position.latitude,longitude:user_position["longitude"]})
position_update.latitude = user_position.latitude;
position_update.longitude = user_position.longitude;
position_update.timestamp = user_position.timestamp
this.setState({currentSearchSelection: "La tua posizione"});
I want to access the data inside the user_position Object, but the output is quite strange:
{user_position: {…}, latitude: undefined, longitude: undefined}
latitude: undefined
longitude: undefined
user_position:
latitude: 41.818550699999996
longitude: 12.495401099999999
timestamp: 1587660938111
__proto__: Object
__proto__: Object
Basically, the user_position is populated but I cannot access the values inside it, what I'm doing wrong?
console.log("user_position:",user_position)to get a better look, or evenconsole.log("keys:",Object.keys(user_position))to see the keys inside. The object does seem to be defined but you can't see the details from your current log statement.