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

FitBit Fetch() Failed to Fetch

Dear Developer Team,

 

I have a question regarding a problem of FitBit Fetch().

In my case are unable to receive the POST fetch message data.

 

Although I connect the Android Phone + FitBit Sense + Computer in the same Wi-Fi,

After using Fetch API in the companion message and run the app is can not get the message result.

 

I have no idea where can I receive the the JSON data on Fetch POST.

as I understand is using the code like this.

 

Send for Post Submission in companion code.

messaging.peerSocket.addEventListener("message", (evt) => {
  fetch('https://localhost:8080/fitbitdata', {
      method: 'POST',
      headers: {
          'Content-Type': 'application/json'
      },
      body: JSON.stringify({
          bpm: evt.data
      })
  })
  .then(response => {
      /*console.log(response);*/ 
  })
  .catch(error => {
      /*console.log(error);*/ 
  });
});

 

Receiver Post Route via Node JS

app.post('/fitbitdata', function(request, response){
    console.log(request.data);
});

 

My environment using NodeJS express for running server and setting a route as127.0.0.1:8080/fitbitdata but the result is fetch is fail.

 

There might be something wrong in this case, is there any suggestions on in problem?

 

Thank you,

 

 

Best Answer
0 Votes
4 REPLIES 4

I think you have to use a numeric IP; see here.

And https probably won't work unless you have a non-self-signed certificate.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Dear Gondwana,

 

Thank you for your help. I will try again by follow the solution.

Best Answer
0 Votes

Hi @Parkpoom - did you resolve this? And on what phone (and OS) is it running?

Author | ch, passion for improvement.

Best Answer
0 Votes

Hello @Guy_ ,

 

Thank you for your reply,

 

I haven't yet resolve but I am trying to use the real server instead, for example, I am using Heroku that provide https server to deploy my Node JS App. Then I plan to send the message by fetch function. I will try again on this solution.

 

I am using both iOS and Android but I can't get access to the localhost of them. I was trying to execute on localhost.

 

Best Answer
0 Votes