Hi
In my app there are lots of api calls so its not possible to check internet connection on every component.
So i want to check internet connection on http interceptor and show a toast message and stop the http request.
My app build with Ionic 4
Hi
In my app there are lots of api calls so its not possible to check internet connection on every component.
So i want to check internet connection on http interceptor and show a toast message and stop the http request.
My app build with Ionic 4
please refer: https://ionicframework.com/docs/native/network
Can you give me a sample code to check online status on a service
To me, that sounds like a strange place to be doing that. By the time an HTTP request is being fired, might as well simply see if it succeeds or not, because you very well may get a false positive from “check internet connection”.
A potentially more useful thing to do would be to proactively disable UI elements that would trigger network requests in the first place when you know there is no viable network connection.
Or use web API:
It has OK support nowadays across browsers.
You create observable and listen to changes for it