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.
Within in the companion, you can use fetch() to send a POST request to an https endpoint.
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
Best Answervar url = 'http://qav2.cs.odu.edu/fitbit/test.php';
var data = {username: 'example'};
function postData(){
fetch(url, {
method: 'POST', // or 'PUT'
body: data, // data can be `string` or {object}!
headers:{
'Content-Type': 'application/text'
}
}).then(res => res)
.then(response => console.log('Success:', response))
.catch(error => console.error('Error:', error));
}
setTimeout(postData, 2000);If I Keep this in companion will it work? or it is not working in my end, Can some tell me how to resolve this issue?
Best AnswerHi, I am also facing a similar issue in my companion code, POST request just isn't firing and not getting any errors either, so a blackbox to debug.
I believe this may be an iOS device related issue. I tested my code in companion and on an Android device and it works seamlessly.
@JonFitbit can you provide some information or guidance regarding this please?
Best Answer