This application communicates between the JS file and HTML file using Socket IO, collecting data and then publishing it to an AWS database using Amazon’s IOT Hub.
I’m trying to figure out a way to make this application load up when offline, cache the transaction data it collects, then when reconnected publish the data to the database.
Right now, if the device has no connection to the internet, the browser says that Localhost is not responding. My first thought was to create a service worker to cache the js/html files and then display the cached versions when offline, but when trying to run the service worker script from the HTML file, it cannot find the service worker script file location (I believe the HTML file moves when running on the browser), and if trying to run it from the js file, I get a Reference Error that “navigator is not defined”.
Can anyone help with some ideas on how to get this running while my device has no connection?