1

I am trying to use timeout in one of my http post. I get error as

ERROR TypeError: this._http.post(...).timeout is not a function

This is how the code looks like:

return this._http.post(this.meetingProcessURL, body )
  .timeout(5000)
  .catch( err => { 
    return Observable.throw("Timeout has occurred");
  })

    .pipe(catchError(this.handleError));
  }

I am using angular 6 and rxjs 6.0.0

"@angular/core": "^6.1.0",
"rxjs": "^6.0.0",
"rxjs-compat": "^6.0.0",

What am I doing wrong?

ref: Angular 2 rxjs timeout callback

enter image description here

ProgSky
  • 2,530
  • 8
  • 39
  • 65

1 Answers1

2

Try this:

return this._http.post(this.meetingProcessURL, body )
  .pipe(
    timeout(5000),
    catchError( err => { 
       return throwError("Timeout has occurred");
    })
  }

Since rxjs@5.5 operators are not part of Observable.prototype, mainly for performance reasons. Read more here

Krzysztof Grzybek
  • 8,818
  • 2
  • 31
  • 35