From 9ecce39a284458598dd30e9248c465ddad3603d3 Mon Sep 17 00:00:00 2001
From: Hugo BAYOUD <hugo.bayoud@etu.uca.fr>
Date: Thu, 25 Mar 2021 22:44:27 +0100
Subject: [PATCH] handle error is bars component fetching bars

---
 src/app/components/bars/bars.component.ts     | 10 +++++-----
 src/app/share/store/effects/bars.effects.ts   |  5 +----
 src/app/share/store/reducers/bars.reducers.ts |  2 --
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/app/components/bars/bars.component.ts b/src/app/components/bars/bars.component.ts
index 361e844d..3ef3a2e2 100644
--- a/src/app/components/bars/bars.component.ts
+++ b/src/app/components/bars/bars.component.ts
@@ -1,5 +1,5 @@
 import { Component, OnInit } from '@angular/core';
-import { Observable } from 'rxjs';
+import { EMPTY, of } from 'rxjs';
 import { catchError, map } from 'rxjs/operators';
 import { Bar } from '../../share/models/bar.model';
 import { BarsService } from '../../share/services/bars.service';
@@ -17,12 +17,12 @@ export class BarsComponent implements OnInit {
   ngOnInit(): void {
 		this.barsService.getAllBars().pipe(
 			map((bars: Bar[]) => {
-				console.log(bars);
 				this.bars = bars;
 			}),
-			catchError((err) => {
-				console.log(err);
-			})
+			catchError((error: any) => {
+				return EMPTY;
+			}
+			),
 		);
 	}
 }
diff --git a/src/app/share/store/effects/bars.effects.ts b/src/app/share/store/effects/bars.effects.ts
index 7205155c..ac47639c 100644
--- a/src/app/share/store/effects/bars.effects.ts
+++ b/src/app/share/store/effects/bars.effects.ts
@@ -24,9 +24,6 @@ export class BarsEffect {
 		}),
 		map((bars: Bar[]) => {
 			return new FetchBarsSuccess(bars);
-		}),
-		// catchError((err) => {
-		// 	console.log(err);
-		// })
+		})
 	);
 }
\ No newline at end of file
diff --git a/src/app/share/store/reducers/bars.reducers.ts b/src/app/share/store/reducers/bars.reducers.ts
index 7c29c885..4f81a013 100644
--- a/src/app/share/store/reducers/bars.reducers.ts
+++ b/src/app/share/store/reducers/bars.reducers.ts
@@ -1,5 +1,3 @@
-import { PhotosAction, PhotosActionsTypes } from "./photos.actions";
-import { Photo } from "../models/photo.model";
 import { Bar } from "../../models/bar.model";
 import { BarsAction, BarsActionsTypes } from "../actions/bars.actions";
 
-- 
GitLab