Guest User

Untitled

a guest
Jan 24th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   async vote(id: string) {
  2.     const post = this.posts.find(value => value.id === id);
  3.     const index = this.posts.indexOf(post);
  4.     post.votes = await VoteService.voteOnPost(this.http, id).then(value => {
  5.       return value
  6.     });
  7.     this.posts[index] = post;
  8.   }
  9.  
  10.  
  11.  
  12.  
  13.   static voteOnPost(http: HttpClient, id: string) {
  14.     return this.vote(http, 'post', id)
  15.   }
  16.  
  17.  
  18.  
  19.  
  20.   private static async vote(http: HttpClient, onWhat: string, id: string) {
  21.     return <number> await http.get("http://localhost:8080/vote/" + onWhat + "/" + id,
  22.       {headers: {'Authorization': localStorage.getItem('Authorization')}}).toPromise();
  23.   }
Advertisement
Add Comment
Please, Sign In to add comment