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

Only when in FitbitAPP, fetch doesn't work.

ANSWERED

Dear Development Team

I am currently trying to GET and POST to a homebrew API.
However, it is not working.
It works well in the fitbit OS simulator and
I have confirmed both GET and POST connections to the API from my smartphone browser as well.
Only in fitbitAPP, it does not work.
Do you know the cause?

Below is the source code that I have reduced to a minimum to determine the cause.

import * as messaging from "messaging";

messaging.peerSocket.addEventListener("message", (evt) => {

fetch('http://172.30.0.63:8001/select/1',{
method: 'GET',
})
.then(json => {console.log(json);})
.catch(error => {console.log(error);})
.then(response => {console.log(response);});
});


The output of console.log(error) is
TypeError:Failed to fetch

Of course, the output of console.log(response) is
undefined


I continue to worry. Please help me.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

On Android, there are only a few IPs you can use without https (for which you'd need a non-self-signed certificate): see here.

 

A recent Fitbit app update broke ALL http from working; see here. There have been a few updates since then, but I don't know whether the problem has been fixed.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
0 Votes
13 REPLIES 13

Companion phone is Android or iOS?

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Hi @TNakamura  - this may have a bearing. No internet connection  especially if you have a recent Android phone, Private DNS may be the issue.

Author | ch, passion for improvement.

Best Answer
0 Votes

Thanks for the reply! I use Android

Best Answer
0 Votes

On Android, there are only a few IPs you can use without https (for which you'd need a non-self-signed certificate): see here.

 

A recent Fitbit app update broke ALL http from working; see here. There have been a few updates since then, but I don't know whether the problem has been fixed.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

@Guy_ Thanks for the reply!

 

I checked the Android settings and the private DNS feature was turned off.
Perhaps this does not affect you?

I'm a newbie, so I don't understand a lot of things, and I'm sorry for the confusion, but thank you in advance for your help!

Best Answer
0 Votes

@TNakamura - are you using 3.65 or later version of the Fitbit App and did you check the other issues in the link I sent?

Author | ch, passion for improvement.

Best Answer
0 Votes

@Guy_ 

The fitbit version must be 3.65 or later, and
not using a VPN connection
Adblock software is not running
security software is not running
Private DNS is not set up.

I have checked everything and there is no change.

Best Answer

The IP address you're trying to use can't work. Did you see my post?

Peter McLennan
Gondwana Software
Best Answer
0 Votes

@TNakamura  - thanks for the feedback, at least you are sure it's none of that. 

3.65.1 will probably make no difference.

Was worth verifying.

Author | ch, passion for improvement.

Best Answer
0 Votes

@Gondwana 

Thanks for getting back to me! I will try the change to https.

But attaching the certificate, that's a pain in the **ahem**...

That helped! Thanks!

Best Answer
0 Votes

Yeah, I gave up trying to install non-self-signed cert on Windows. You can normally use http on the same device as the Fitbit app (ie, your phone). Or use https to a full-on web server or service; eg, Heroku.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

@Gondwana 

 

Thanks for the info!

Regarding the former, is that meant to be an API embedded in the phone itself?

I'm learning a lot about Heroku, etc. I will look into it. Thanks!

Best Answer
0 Votes

On the phone, I've used node.js hosted within dory-node, and also written a native Java app accessing the Android API. I think the latter is on the Fibit ossapps repo.

Peter McLennan
Gondwana Software
Best Answer
0 Votes