I have the following code
$locationButton.onclick = () => {
if(!navigator.geolocation) { return alert('method unavailable'); }
$locationButton.setAttribute('disabled', 'disabled');
navigator.geolocation.getCurrentPosition((position) => {
console.log(position)
$locationButton.removeAttribute('disabled');
socket.emit('USER:SEND_LOCATION', position, (response) => {
console.log(response)
});
})
}
and on server
socket.on('USER:SEND_LOCATION', (position: any, callback: Function) => {
console.log(position)
const timestamp = Date.now();
socket.broadcast.emit('SERVER:NEW_LOCATION', {position, timestamp, user: 'Me'});
callback({position, timestamp, user: 'Me'});
})
The problem I have is, in client, there is a position object on the first console.log, then I try send it do the server, and the server always get only an empty object instead '{}'
I tried json.strigify, but I sill get a '{}'