8000 Feature Request: interceptor to accept promise · Issue #61451 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content

Feature Request: interceptor to accept promise #61451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its m 8000 aintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
coder-ashwin opened this issue May 17, 2025 · 0 comments
Open

Feature Request: interceptor to accept promise #61451

coder-ashwin opened this issue May 17, 2025 · 0 comments
Labels
area: common/http Issues related to HTTP and HTTP Client
Milestone

Comments

@coder-ashwin
Copy link
coder-ashwin commented May 17, 2025

Which @angular/* package(s) are relevant/related to the feature request?

common

Description

With the release of httpResource, it would be great for the interceptor function to accept a promise so that RxJs dependency can be removed here as well. Currently, it only accepts an observable.

Proposed solution

export function interceptor(request: HttpRequest<unknown>, next: HttpHandlerFn): Promise<HttpEvent<unknown>> {
  // before api logic

  return next(request).then(result => {
      // tap logic
  }).catch((requestError: HttpErrorResponse) => {
      // error logic
  });
}

Instead of

export function interceptor(request: HttpRequest<unknown>, next: HttpHandlerFn): Observable<HttpEvent<unknown>> {
  // before api logic

  return next(request).pipe(
    tap(result => {
      // tap logic
    }),
    catchError((requestError: HttpErrorResponse) => {
      // error logic
      return throwError(() => requestError);
    })
  );
}
@coder-ashwin coder-ashwin changed the title interceptor as promise Feature Request: interceptor as promise May 17, 2025
@coder-ashwin coder-ashwin changed the title Feature Request: interceptor as promise Feature Request: interceptor to accept promise May 17, 2025
@JeanMeche JeanMeche added the area: common/http Issues related to HTTP and HTTP Client label May 17, 2025
@ngbot ngbot bot added this to the needsTriage milestone May 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: common/http Issues related to HTTP and HTTP Client
Projects
None yet
Development

No branches or pull requests

2 participants
0