diff --git a/src/app/comment.service.ts b/src/app/comment.service.ts index 82a5f77f6a7046858c388afa07347aa8a6716390..635c2eddaf63750b32145023c4ab56fe3dd1e2a1 100644 --- a/src/app/comment.service.ts +++ b/src/app/comment.service.ts @@ -1,8 +1,21 @@ import { Injectable } from '@angular/core'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; + +import { Observable } from 'rxjs/Observable'; + + +const httpOptions = { + headers: new HttpHeaders({ 'Content-Type': 'application/json' }) +}; @Injectable() export class CommentService { + private commentsUrl = 'api/comments'; - constructor() { } + constructor( private http: HttpClient ) { + } + addComment(comment: Comment): Observable<Comment> { + return this.http.post<Comment>(this.commentsUrl, comment, httpOptions); + } }