1
|
import { Injectable } from '@angular/core';
|
2
|
import {HttpClient, HttpErrorResponse, HttpHeaders} from '@angular/common/http';
|
3
|
import {throwError} from 'rxjs';
|
4
|
import {environment} from '../../environments/environment';
|
5
|
|
6
|
@Injectable({
|
7
|
providedIn: 'root'
|
8
|
})
|
9
|
export class BasicService {
|
10
|
protected baseUrl = environment.apiUrl;
|
11
|
|
12
|
protected handleError(error: HttpErrorResponse) {
|
13
|
if (error.error instanceof ErrorEvent) {
|
14
|
console.error('An error occurred:', error.error.message);
|
15
|
} else {
|
16
|
console.error(
|
17
|
`Backend returned code ${error.status}, ` +
|
18
|
`body was: ${error.error}`);
|
19
|
}
|
20
|
return throwError(
|
21
|
'Something bad happened; please try again later.');
|
22
|
}
|
23
|
|
24
|
constructor(protected http: HttpClient) { }
|
25
|
}
|