aboutsummaryrefslogtreecommitdiff
path: root/sandbox/test-projekat-danijel/frontend/src/app/values.service.ts
blob: a76555ee3e46004837d78724d6e7b79b8ace8833 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class ValuesService {

  constructor(private http: HttpClient) { }

  getColors() {
    return this.http.get<string[]>(`http://localhost:5000/api/values/`);
  }

  addColor(red: number, green: number, blue: number) {
    let header: HttpHeaders = new HttpHeaders({
      'Content-type': 'application/json',
    });
    return this.http.post(`http://localhost:5000/api/values/`, { red, green, blue }, { headers: header, responseType: 'text' });
  }
}