Angular 2 (TypeScript) Handle empty json Response from Http Angular 2 (TypeScript) Handle empty json Response from Http json json

Angular 2 (TypeScript) Handle empty json Response from Http


Even it is an empty array, it is still a valid response.You can use array.length to handle this.

if (data && data.length > 0) {    // do something} else {    this.errorMsg = "Nothing Found";}