Unable to find network status

Hi team,

unable to find whether the app is already connected to network or not.
I tried with ionic network native plugin but it gives network status only on an event such as network change, disconnection and on a new connection if network was disconnected on app start.

checkForNetwork(){
console.log(“NETWORK SERVICE”,this.network,this.network.type)
return new Promise((resolve,reject)=>{
this.connected = this.network.onConnect().subscribe(data => {
console.log(“onlineeee”,data)
this.networkDetail.connected=true;
this.networkDetail.networkType=this.network.type;
resolve(this.networkDetail)
this.displayNetworkUpdate(data.type);
}, error =>{ console.log(error)
resolve()
});

          this.disconnected = this.network.onDisconnect().subscribe(data => {
            console.log(data)
            this.networkDetail.connected=false;
            this.networkDetail.networkType=this.network.type;
            reject(this.networkDetail)
            this.displayNetworkUpdate(data.type);
          }, error =>
          { console.log(error)
            resolve()
        });
    })
    
}

Goal : check if network is available then call api otherwise show error

Thanks

Some ideas in here: Ionic: How to detect connected to internet with no access

Hello…
I did this in my case:

        if(this.checkConnection()){
		this.navCtrl.setRoot(WelcomePage, {
			loading: loading
		});
	} else {
		this.navCtrl.setRoot(NoNetworkPage,{
			loading: loading
		});
	}

    ...

   checkConnection() {
	var networkState = this.network.type;
	if(networkState == 'none'){
		return false;
	} else {
		return true;
	}
     }

I hope I help…

my device is connected but getting network type as null

Something is going wrong. This plugin returns only these types (unknown, ethernet, wifi, 2g, 3g, 4g, cellular, none)

exactly but don’t know whats going wrong??/?