Show no internet connection if trying to make http request

#1

I used Ionic network to subscribe to internet connection status but I want to show a message say “No internet connection” when making a request and there is no connection.

#2

What code do you have so far? How does what it do differ from what you want it to do?

#3

this code only shows a message when the connection gone or back, what I need is to show a msg to the user if he clicked a button to fetch data from api .

// Handle Network connection
    this.network.onConnect().subscribe(data => {
      this.presentToast("You are Connected");
      console.log(data)
    }, error => console.error(error));

    this.network.onDisconnect().subscribe(data => {
      this.presentToast("You are Offline");
      console.log(data)
    }, error => console.error(error));
#4

The Observable returned from the http request should throw an error in that situation that you can respond to.