How to check if the Server is Up or Down in ionic


#1

Hi just want to know how can I know whether Server is Up or Down in ionic so if my network connection is ok but server not ok then I just want to cancel the loading and display an alert
Thanks


#2

Try to connect to it. If it works, it works. If it doesn’t, it doesn’t.


#3

didn’t get this … :confused:

Try to connect to it. If it works, it works. If it doesn't, it doesn't.

but what I came to know is at the time of posting if it takes took much time it will automatically come to error function …
thanks


#4

I have no idea what this is intended to mean.


#5

something like below

this.http.post(url, body, options).map(res => res.json())
        .subscribe((data) => {
           this.loading.dismissAll();                 
        }, error => {
         this.loading.dismissAll();
         this.dialogs.alert('Taking too much time for response please try again...');
         return;
        });

#6

Now you know the server is down for this device.


#7

it can be up or down depends on server


#8

Yes it does.

But for that user with that device it timed out, so it is “down” for them.