24 lines
631 B
TypeScript
24 lines
631 B
TypeScript
import {Injectable} from '@angular/core';
|
|
import {HttpClient} from '@angular/common/http';
|
|
import {Customer} from '../models/customer';
|
|
import {Observable} from 'rxjs';
|
|
import {environment} from '../../environments/environment';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class CustomerService {
|
|
baseApi = `${environment.baseApi}/customers`;
|
|
|
|
constructor(private http: HttpClient) {
|
|
}
|
|
|
|
getCustomers(): Observable<Customer[]> {
|
|
return this.http.get<Customer[]>(`${this.baseApi}`);
|
|
}
|
|
|
|
addCustomer(customer: Customer): Observable<Customer> {
|
|
return this.http.post<Customer>(`${this.baseApi}`, customer);
|
|
}
|
|
}
|