🧠
ngx-crud
  • Introduction
  • API
    • HTTP Operations
    • HTTP Aborting
    • HTTP Caching
    • HTTP Observing
    • HTTP Options
    • HTTP Context
    • HTTP Headers
    • HTTP Params
    • Service Instance
    • Service Options
  • Reference
    • Modules
      • AbortModule
      • CacheModule
      • ObserveModule
      • CrudModule
    • Services
      • AbortService
      • CacheService
      • CommonService
      • CrudService
      • CustomService
      • DeleteService
      • FindService
      • GetService
      • ObserveService
      • PatchService
      • PostService
      • PutService
    • Interceptors
      • AbortInterceptor
      • CacheInterceptor
      • ObserveInterceptor
    • Decorators
      • @ApiUrl
      • @ApiRoute
    • Helpers
      • createUrl
      • createUrlWithId
      • stripUrlParams
  • Examples
    • Services
      • Fully Typed Collection
      • Limited Singleton
    • Components
      • Loader
    • Effects
      • ProfilerEffect
      • ErrorEffect
      • OfflineEffect
  • Links
    • GitHub
Powered by GitBook
On this page
  1. Examples
  2. Effects

ErrorEffect

Show an error message on unsuccessful requests:

import { Injectable } from '@angular/core';
import { HttpRequest } from '@angular/common/http';
import { ObserveAfterEffect } from 'ngx-crud';

import { NotifierService } from './notifier.service';

@Injectable()
export class ErrorEffect implements ObserveAfterEffect
{
	constructor(protected notifierService : NotifierService) {}

	after<T>(request: HttpRequest<T>, response: HttpResponse<T> | HttpErrorResponse): void
	{
		if (response instanceof HttpErrorResponse)
		{
			notifierService.error('REQUEST_ERROR');
		}
	}
}
PreviousProfilerEffectNextOfflineEffect

Last updated 3 years ago