Skip to main content

Posts

Showing posts with the label Angular 4 Error handling

Kendo UI Angular 4 Setting Up Project

Kendo UI Installation Instructions in Angular 4– Step 1- Installation npm install - g @ angular / cli ng new my - first - angular - project -- style = scss cd my - first - angular - project Step 2 - npm install -- save @ progress / kendo - angular - buttons @ progress / kendo - angular - l10n @ angular / animations Step 3 - npm install -- save @ progress / kendo - theme - default Step 4 - Once installed, import the NgModule of the components you need Example - import the DropDownsModule import { NgModule } from '@angular/core' ; import { BrowserModule } from '@angular/platform-browser' ; import { BrowserAnimationsModule } from '@angular/platform-browser/animations' ; import { DropDownsModule } from '@progress/kendo-angular-dropdowns' ; import { AppComponent } from './app.component' ; @ NgModule({ bootstrap : [AppComponent], declarations : [AppComponent], imports : [BrowserModule, BrowserAnima...

Angular 4 Error Handling - Logging, Retry Request and HttpCache!

What Happens If the Request fails on the Server Due to Poor Network Connection? HttpClient will return an error instead of a successful response. Example - Add an error handler to handle the errors http.get( '/api/users' ) .subscribe(data => {console.log(data);}, //Successful responses call the first callback. err => {console.log( 'Got error!' ); //Errors - Something went wrong! }); How To Get and Log an error in Angular 4? Two types of errors - 1.      If the backend returns an unsuccessful response like - 404, 500 and so on 2.      If something goes wrong in the client side like -network error etc. In the both cases - We are using HttpErrorResponse and return the useful information on what went wrong in this call! Example – http.get( '/api/users' ) .subscribe(data => {console.log(data);}, //Successful responses call the first callback. (err : HttpErrorResponse) => { i...