import { Injectable } from '@angular/core' ; import { Response } from "@angular/http" ; import { Observable } from "rxjs" ; @ Injectable ( ) export class ApiErrorService { constructor ( ) { } getFirstError ( responseJson ) { let errors = responseJson [ 'errors' ] ; if ( errors && errors . length ) { return errors [ 0 ] ; } } getFieldErrors ( responseJson , field ) { let errors = responseJson [ 'errors' ] ; let results = [ ] ; if ( errors && errors . length ) { for ( var errorObject in errors ) { } return results ; } } }