Handling connection error with Observables

I am trying to handle connection error or connection disconnect

Servic.ts:

    load(): Observable<Jobs[]>{
       return this.http.get(this.jobsApiUrl)
        .retry(2)
        .map(res => <Jobs[]>(res.json().data))
       
      }

.ts :

   jobsData.load().subscribe(res => {
      this.jobs = res;
     
      })

how do I handle connection error . for example internet disconnected ??

Hi @yasirpanjsheri did you found a solution for that?

Hi…use Network from ionic native to watch for network diconnection

Me too, I check on the http interceptor if the device is disconnected and if yes I give a different error like ‘You are not connected’. Is that what you are doing also?

On http interceptor !! Can you show an example!
I havent really gone far down this road. When I asked the question, I was thinking that there might be a way to detect connection while sending a request (maybe observable has some way to do it)… right now im only catching error if the observable throws any… for connection, I made a service and injected it in app.component.ts and only watching for disconnect and display a toast…nothing more than that.

Y’all might want to either wait for Ionic to support Angular 4.3+ or go rogue and install it yourself now anyway. The new HttpClient API makes writing HTTP interceptors a breeze.

you mean updating from 4.1.3 to 4.3.xx ? Will it work?

I can’t say definitively yet whether it works with the current Ionic version, but I have not yet run into any problems either.

which angular version did you install exactly ?

4.3.6, but I have to stress that this is unsupported and you will get peer dependency errors. If things break, you get to keep both halves.