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');
		}
	}
}

Last updated