Utilizing the Axios Http Client on my website poses a challenge when it comes to obtaining the user's location through the browser's geolocation feature. Once the location is acquired, I aim to send this data along with other information. To accomplish this, I have constructed a data object structured as follows:
navigator.geolocation.getCurrentPosition(
function(position) {
var data = {
id: 1,
user:'me',
location: position
};
})
;
Subsequently, attempting to transmit the data via Axios yields a puzzling outcome:
axios.put('/my-endpoint', data, options)
.then(function(res) {
console.log('success');
console.log(res);
})
;
Although I receive a positive response from the request, upon inspecting the logs, an anomaly surfaces - the location
property appears as an empty object. This discrepancy becomes evident especially when comparing the browser's logged output which displays correct values for location
, contrary to what Fiddler reveals where it is empty during transmission. How is this possible?
This discrepancy leads me to believe there might be a particular configuration or step required to facilitate sending nested JavaScript objects across networks, yet nothing stands out. What could I potentially be overlooking? For demonstration purposes, I've provided a simple JSFiddle showcasing the issue here.