How to set a timer for provider to show a message if not return a value?

Friends,
I have a form with combo values load based on the provider data… If there is no data for that provider the loader spins indefinitely.I need to show a reasonable message like “The Service not available” after some time .

My relevant code is

getZonalOffice(lbid,lbtype) {
   let loader = this.loadingController.create({
     content: "Loading Zonal Office ... "
     });  
   loader.present();
   this.propertyProvider.getZonalOffice(lbid)
   .then(data => {
     if(lbtype == 5 || lbtype == 3) {
       data.shift();
     }  
     alert(JSON.stringify(data)); // it will not work when no data available
     this.zonaloffices = data;
     //changed code below
     if(this.zonaloffices.length == 1 && this.zonaloffices[0].zonal_name_eng == "Main Office") {
       this.data.zonaloffice = this.zonaloffices[0].zonal_id;  
     }
     loader.dismiss();
   })
 }

Please advise

Thanks
Anes

Hi @anespa
You have to catch the error while returns a promise.
Inside that catch you can show a toast or alert.

this.propertyProvider.getZonalOffice(lbid)
   .then((data) => {
        // do in successs
     })
   .catch(err => {
       // do in fails show the message here
           loader.dismiss();
          let toast = this.toastCtrl.create({
           message: 'The Service not available',
           duration: 3000,
          position: 'bottom'
      });
      These may helps you