Ignore:
Timestamp:
12/19/21 19:39:00 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
bdd6491
Parents:
1ad8e64
Message:

spring security 2.0

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";
     1import { HttpClient, HttpHeaders } from "@angular/common/http";
    22import { Injectable } from "@angular/core";
    33import { Observable } from "rxjs";
     
    88    providedIn: 'root'
    99})
    10 export class PlannerService{
    11    
     10export 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
    1219    constructor(private httpClient: HttpClient){
    1320    }
    1421
     22   
    1523    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});     
    1828    }
    1929
    20     postInitialPlanner(planner: Planner): Observable<Object>{     
     30    postInitialPlanner(planner: Planner): Observable<Planner>{     
    2131        let url = "http://localhost:8080/api/planner/new";
    2232        return this.httpClient.post<Planner>(url, planner);
     
    2535    updatePlanner(id: number, plannerDto : PlannerDto):Observable<Planner>{   
    2636    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});
    2838    }
    2939
Note: See TracChangeset for help on using the changeset viewer.