Ignore:
Timestamp:
02/06/22 18:15:51 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
571e0df
Parents:
76712b2
Message:

add location feature

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/src/app/_services/location.service.ts

    r76712b2 r6fe77af  
    1 import { HttpClient } from "@angular/common/http";
     1import { HttpClient, HttpHeaders } from "@angular/common/http";
    22import { Injectable } from "@angular/core";
    33import { Observable } from "rxjs";
     4import { LocationDto } from "../_models/dto/locationDto";
    45import { PlannerLocationDto } from "../_models/dto/plannerLocationDto";
    56import { Location } from "../_models/location";
     
    910})
    1011export class LocationService{
     12
     13    httpHeaders: HttpHeaders = new HttpHeaders({
     14        'Authorization': '' + sessionStorage.getItem("token"),
     15        'Accept': 'application/json',
     16        'Content-Type': 'application/json'
     17    });
     18
    1119    constructor(private httpClient : HttpClient){}
    1220
     
    6573        return this.httpClient.get<Location[]>(url + "?place=" + place);
    6674    }
     75
     76    save(locationDto : LocationDto) : Observable<Location>{
     77        let url = "http://localhost:8080/api/add";
     78        return this.httpClient.post<Location>(url, locationDto, {headers: this.httpHeaders});
     79    }
    6780}
Note: See TracChangeset for help on using the changeset viewer.