Hello, a year ago I transferred data from companion to a server with this code:
// Listen for the onmessage event
messaging.peerSocket.onmessage = function(evt) {
// Output the message to the console
console.log(JSON.stringify(evt.data));
// Send information to the server
fetch('https://XXXX.es:3000/heartRate', {
method:'post',
headers: {
'Content-Type': 'application/json'
},
body:JSON.stringify(evt.data)
}).then(function(result) {
if (!result.ok) {
console.log(result.status + ': ' + result.statusText);
return;
}
console.log('Enviado paquete');
}).catch(function (err){
console.log(err)
})
}Now i can't use that server anymore and i would like to fetch to localhost:3000. It's where my nodeJS server can listen
//nodeJS server.js code
[...]
https.createServer(options, app).listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening on ${port}`) });
[...]Is there a possibility to send data to my localhost through the companion? Later I need to insert that data in a mongo database with that server.js
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.