I have a web page that is using the Axios Http Client. In my web page, I'm getting my location using the browser's geolocation feature. When my location is obtained, I want to send that location, along with other data. To do this, I've built data object like this:
navigator.geolocation.getCurrentPosition(
function(position) {
var data = {
id: 1,
user:'me',
location: position
};
})
;
I then try to send the data via Axios like this:
axios.put('/my-endpoint', data, options)
.then(function(res) {
console.log('success');
console.log(res);
})
;
I get a successful response back from this request. However, it's a false positive. When I look at the logs, it's weird. I can see that the location property is an empty object. So, I did a console.log in the browser and I can see that location is properly set. But when I send it via Fiddler, I notice that it's not there. It's just an empty object when it goes across the wire. How?
I suspect there is some setting or something else I have to do to send a nested JavaScript object over the network. But I don't see anything. What am I doing wrong? I've made a basic JSFiddle here with this code..