0

setting timeout in catcherror shows error in angular

Argument of type (error: any) => void is not assignable to parameter of type (err: any, caught: Observable<HttpEvent<any>>) => ObservableInput<{}>. Type void is not assignable to type ObservableInput<{}>. [2345]

https://i.stack.imgur.com/qUK4J.png

          catchError(error => {
           if(error==403)
           {
            setTimeout(() => {
                return next.handle(this.addToken(req,  authService.getToken())).pipe();
            }, 2000);
           }

        })
Najam Us Saqib
  • 3,190
  • 1
  • 24
  • 43
Vishnudas
  • 229
  • 2
  • 10
  • 1
    Returning from `setTimeout` makes no sense as it is an async operation. You need to reconsider your workflow. – Harun Yilmaz Jan 03 '19 at 09:29
  • 2
    You can do like `return next.handle(this.addToken(req, authService.getToken())).pipe(delay(2000));` without `setTimeout` – Harun Yilmaz Jan 03 '19 at 09:30
  • `return next.handle(request).pipe(catchError(` try this – super cool Jan 03 '19 at 09:32
  • Possible duplicate of [Type 'void' is not assignable to type 'ObservableInput<{}>'](https://stackoverflow.com/questions/43115390/type-void-is-not-assignable-to-type-observableinput) – CTheCheese Jan 03 '19 at 09:33
  • Thanks for the comments , i tried all ways but not worked in my case so i changed my work flow :) – Vishnudas Jan 04 '19 at 06:27

1 Answers1

0

Use delay inside the pipe, like .pipe(delay(2000))