-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata-storage.service.ts
31 lines (27 loc) · 1.12 KB
/
data-storage.service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { HttpClient, HttpHeaders } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { RecipeService } from "./recipe.service";
@Injectable()
export class DataStorageService {
constructor(private http: HttpClient, private recipeService: RecipeService) {}
updateData(data: any) {
let headers = new HttpHeaders({ "content-type": "application/json" });
let url = `http://domain.com/path?query=true`;
return this.http.put<type>(url, data, { headers: headers });
}
fetchData() {
let headers = new HttpHeaders({ "content-type": "application/json" });
let url = `http://domain.com/path?query=true`;
return this.http.get<type>(url, { headers: headers });
}
createData(data: any) {
let headers = new HttpHeaders({ "content-type": "application/json" });
let url = `http://domain.com/path?query=true`;
return this.http.post<type>(url, data, { headers: headers });
}
deleteData(id: number) {
let headers = new HttpHeaders({ "content-type": "application/json" });
let url = `http://domain.com/${id}`;
return this.http.delete<type>(url, { headers: headers });
}
}