Created
April 19, 2020 12:32
-
-
Save stefansheva/49427cdf3240ccdfebd3ba245fb10be5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
import { environment } from '../environments/environment'; | |
import { map } from 'rxjs/operators'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class PostService { | |
constructor(private http: HttpClient) { } | |
getAllPosts() { | |
return this.http.get(`${environment.apiUrl}/posts`).pipe(map(res => res)); | |
} | |
getPost(postId) { | |
return this.http.get(`${environment.apiUrl}/posts/${postId}`).pipe(map(res => res)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment