From 4d64a57591585dfc2d0aedea8152e4ef1f0704a9 Mon Sep 17 00:00:00 2001 From: Spencer Ofwiti Date: Wed, 7 Apr 2021 10:25:41 +0300 Subject: [PATCH] Handle parsing of empty arrays. --- src/app/_helpers/export-csv.ts | 2 +- src/app/_interceptors/error.interceptor.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/_helpers/export-csv.ts b/src/app/_helpers/export-csv.ts index 6962ae0..7100842 100644 --- a/src/app/_helpers/export-csv.ts +++ b/src/app/_helpers/export-csv.ts @@ -1,5 +1,5 @@ function exportCsv(arrayData: any[], filename: string, delimiter = ','): void { - if (arrayData === undefined) { return; } + if (arrayData === undefined || arrayData.length === 0) { return; } const header = Object.keys(arrayData[0]).join(delimiter) + '\n'; let csv = header; arrayData.forEach(obj => { diff --git a/src/app/_interceptors/error.interceptor.ts b/src/app/_interceptors/error.interceptor.ts index 1aef324..96c404f 100644 --- a/src/app/_interceptors/error.interceptor.ts +++ b/src/app/_interceptors/error.interceptor.ts @@ -1,4 +1,4 @@ -import {Injectable, isDevMode} from '@angular/core'; +import {Injectable} from '@angular/core'; import { HttpRequest, HttpHandler,