restaurants.service.ts 578 B

123456789101112131415161718192021222324
  1. import { Restaurant } from './../models/restaurant';
  2. import { Injectable } from '@angular/core';
  3. import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
  4. import { Observable } from 'rxjs';
  5. import { environment } from 'src/environments/environment';
  6. @Injectable({
  7. providedIn: 'root'
  8. })
  9. export class RestaurantsService {
  10. constructor(private http : HttpClient) { }
  11. //url api
  12. private apiUrl = environment.apiUrl
  13. // get users
  14. getRestaurants(): Observable<Restaurant[]> {
  15. return this.http.get<Restaurant[]>(`${this.apiUrl}/api/restaurants`);
  16. }
  17. }