|
@@ -0,0 +1,29 @@
|
|
1
|
+import { HttpClient } from '@angular/common/http';
|
|
2
|
+import { Injectable } from '@angular/core';
|
|
3
|
+
|
|
4
|
+/*
|
|
5
|
+ Generated class for the RestProvider provider.
|
|
6
|
+
|
|
7
|
+ See https://angular.io/guide/dependency-injection for more info on providers
|
|
8
|
+ and Angular DI.
|
|
9
|
+*/
|
|
10
|
+@Injectable()
|
|
11
|
+export class RestProvider {
|
|
12
|
+
|
|
13
|
+ apiUrl = 'https://fast-headland-39537.herokuapp.com';
|
|
14
|
+
|
|
15
|
+ constructor(public http: HttpClient) {
|
|
16
|
+ console.log('Hello RestServiceProvider Provider');
|
|
17
|
+ }
|
|
18
|
+
|
|
19
|
+ getPosts() {
|
|
20
|
+ return new Promise(resolve => {
|
|
21
|
+ this.http.get(this.apiUrl+'/posts/all').subscribe(data => {
|
|
22
|
+ resolve(data);
|
|
23
|
+ }, err => {
|
|
24
|
+ console.log(err);
|
|
25
|
+ });
|
|
26
|
+ });
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+}
|