11-20-2019 03:12
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-20-2019 03:12
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hello fellow Fitbit developers,
I have developed an app that get the heart rate from a fitbit ionic device and sends it to the android companion. The companion is connected to a hotspot created by my laptop, which hosts a local Flask server.
When trying to POST the data from the companion to the Flask server, I get this error message
```
TypeError: Failed to fetch
```
The weird thing is that I can perform POST from a terminal I have installed in my phone, but the companion cannot perform the request itself. This is my code for fetch:
method:'post',
headers: {
'Content-Type': 'application/json'
},
body:JSON.stringify(evt.data)
}).then(function(result) {
if (!result.ok) {
console.log('error');
return;
}
console.log('send ok');
}).catch(function (err){
console.log(err);
})
Do you have any idea what is going on?
Answered! Go to the Best Answer.

Accepted Solutions
11-20-2019 22:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


11-20-2019 22:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
While you're supposed to be able to use http for localhost, I think that's currently broken (it wants https in all cases(!)).
I think this is a known issue; a fix has been promised.
Gondwana Software

11-20-2019 22:02 - edited 11-20-2019 22:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


11-20-2019 22:02 - edited 11-20-2019 22:15
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi @OrestisZekai,
I think your thread may find a better home, rather than where it was originally posted in the general Ionic customer support forum. We have two dev forums, one for the SDK and one for the Web API. From your code snippet, it looks like the Web API forum may be the place for it, so I'll move it there. If I'm incorrect, just let me know here and I can place it in the SDK forum..

11-20-2019 22:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


11-20-2019 22:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
While you're supposed to be able to use http for localhost, I think that's currently broken (it wants https in all cases(!)).
I think this is a known issue; a fix has been promised.
Gondwana Software

11-21-2019 02:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-21-2019 02:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hello @Gondwana,
looks like you are correct. I set up the same Flask server in a secure webserver over https and I can finally get messages through.
But I really hoped I would be able to do it all in my hotspot. Thanks anyway

