Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can i send a JSON data from ionic frame work(from fitbit stud) to php file using post request?

Please  I wanted to send data from fibit studio app to php file as a post request.

Best Answer
0 Votes
3 REPLIES 3

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 Answer
0 Votes
var 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 Answer
0 Votes

Hi, 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
0 Votes