Changeset 84d0fbb for trip-planner-front/src/app/_services
- Timestamp:
- 12/19/21 19:39:00 (3 years ago)
- Branches:
- master
- Children:
- bdd6491
- Parents:
- 1ad8e64
- Location:
- trip-planner-front/src/app/_services
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/src/app/_services/planner.service.ts
r1ad8e64 r84d0fbb 1 import { HttpClient } from "@angular/common/http";1 import { HttpClient, HttpHeaders } from "@angular/common/http"; 2 2 import { Injectable } from "@angular/core"; 3 3 import { Observable } from "rxjs"; … … 8 8 providedIn: 'root' 9 9 }) 10 export class PlannerService{ 11 10 export class PlannerService { 11 12 httpHeaders: HttpHeaders = new HttpHeaders({ 13 'Authorization': ''+sessionStorage.getItem("token"), 14 'Accept': 'application/json', 15 'Content-Type': 'application/json' 16 }); 17 18 12 19 constructor(private httpClient: HttpClient){ 13 20 } 14 21 22 15 23 getAllPlanners():Observable<Planner[]>{ 16 let url = "http://localhost:8080/api/planners"; 17 return this.httpClient.get<Planner[]>(url); 24 let url = "http://localhost:8080/api/planners/user"; 25 console.log("SERVID: " + sessionStorage.getItem("token")); 26 console.log(this.httpHeaders.get('Authorization')) ; 27 return this.httpClient.get<Planner[]>(url, {headers: this.httpHeaders}); 18 28 } 19 29 20 postInitialPlanner(planner: Planner): Observable< Object>{30 postInitialPlanner(planner: Planner): Observable<Planner>{ 21 31 let url = "http://localhost:8080/api/planner/new"; 22 32 return this.httpClient.post<Planner>(url, planner); … … 25 35 updatePlanner(id: number, plannerDto : PlannerDto):Observable<Planner>{ 26 36 let url = "http://localhost:8080/api/edit/planner/" + id; 27 return this.httpClient.put<Planner>(url, plannerDto );37 return this.httpClient.put<Planner>(url, plannerDto, {headers: this.httpHeaders}); 28 38 } 29 39
Note:
See TracChangeset
for help on using the changeset viewer.