Added news part to feature toggling

This commit is contained in:
Erik Tiekstra
2021-11-12 09:30:49 +01:00
parent 0235f1f912
commit 481e4686a2
4 changed files with 16 additions and 11 deletions

View File

@@ -5,7 +5,7 @@ import { environment } from '@msfa-environment';
import { NewsResponse } from '@msfa-models/api/news.response.model';
import { CustomError } from '@msfa-models/error/custom-error';
import { ErrorService } from '@msfa-services/error.service';
import { BehaviorSubject, Observable } from 'rxjs';
import { Observable } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
@Injectable({
@@ -13,14 +13,10 @@ import { catchError, map } from 'rxjs/operators';
})
export class NewsApiService {
private _apiBaseUrl = `${environment.api.url}/confluence/nyheter`;
private _newsLoading$ = new BehaviorSubject<boolean>(false);
public newsLoading$: Observable<boolean> = this._newsLoading$.asObservable();
constructor(private http: HttpClient, private errorService: ErrorService) {}
public fetchNews$(): Observable<NewsResponse> {
this._newsLoading$.next(true);
return this.http.get<{ data: NewsResponse }>(this._apiBaseUrl).pipe(
map(({ data }) => data),
catchError((error: Error) => {