Send localstorage data to DB inside the code of my Bluetooth

image

This is the conditional statement of my bluetooth code whenever my device receives exact raw data of 31, the saved text data inside localstorage will begin to send to the database but I cannot make it work. I suspecting that it uses the bluetooth connection and not the wifi. Please help