projects.service.ts 610 B

12345678910111213141516171819202122232425
  1. import { Injectable } from '@angular/core';
  2. import { HttpClient } from '@angular/common/http';
  3. import { Observable } from 'rxjs';
  4. import { Projects } from '../models/projects';
  5. import { Project } from '../models/project';
  6. @Injectable({
  7. providedIn: 'root'
  8. })
  9. export class ProjectsService {
  10. apiUrl = 'http://localhost:8080/api/projects/';
  11. constructor(private http: HttpClient) {}
  12. getAllProjects(): Observable<Project[]> {
  13. return this.http.get<Project[]>(this.apiUrl);
  14. }
  15. getProject(permalink: String): Observable<Project> {
  16. return this.http.get<Project>(this.apiUrl + permalink);
  17. }
  18. }