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

Send data (json) from ionic companion to local mysql database

ANSWERED

Hi,

 

I made sideload app for collecting accelerometer data, and I checked sending data to compaion through messenger API.

 

Now, I want to send my data to local mysql database in my macbook.

 

I found 'fetch api' that can post data to the web in documents.

 

Can I use this api for sending my data from companion to mysql database?Smiley Sad

 

I would like to hear advice if you have experience with it.Smiley Happy

 

 

 

 

 

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

If you are using your local IP address in your fetch API on the companion then when you go off your local wifi, this local IP address is no longer available which will prevent the transfer. In the case of your phone being connected to a different internet network such as 4G you would need to access your servers external IP address which will be completely different. The issue with this method is that due to it now being considered an external IP address you need to self certify that server and connect via https.

View best answer in original post

Best Answer
0 Votes
4 REPLIES 4

Firstly, Messenger API can be unreliable. My recommendation is to store the data on the watch and once you are done transfer using the file transfer API.

 

Fetch is the only way to get data from the fitbit off your phone (companion). You will need to host a server that can handle your fetch APIs . If its local, http works, if its not you need to self certify the server to get https.

 

Once your server can handle the requests then its just a matter of syncing your database to the server so the server can write the data it receives to the database.

 

Best Answer
0 Votes

Thank you for your reply!Smiley Happy

 

I succeeded in sending data to the web server via the fetch api.

 

But, Now I have a another issue!Smiley Sad

 

I noticed that only when the companion and my MacBook installed the web server were connected to the same WiFi, the data transmission was done.

 

Not surprisingly, stopping the Wi-Fi connection on the phone(companion) stopped the data transfer.

 

I would like to advise you on how to make phone(companion) send data to a web server without being connected to Wi-Fi.

Best Answer
0 Votes

If you are using your local IP address in your fetch API on the companion then when you go off your local wifi, this local IP address is no longer available which will prevent the transfer. In the case of your phone being connected to a different internet network such as 4G you would need to access your servers external IP address which will be completely different. The issue with this method is that due to it now being considered an external IP address you need to self certify that server and connect via https.

Best Answer
0 Votes

Thank you for your reply!Smiley Happy

 

I solved my problem!

 

 

Best Answer
0 Votes