Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async vote(id: string) {
- const post = this.posts.find(value => value.id === id);
- const index = this.posts.indexOf(post);
- post.votes = await VoteService.voteOnPost(this.http, id).then(value => {
- return value
- });
- this.posts[index] = post;
- }
- static voteOnPost(http: HttpClient, id: string) {
- return this.vote(http, 'post', id)
- }
- private static async vote(http: HttpClient, onWhat: string, id: string) {
- return <number> await http.get("http://localhost:8080/vote/" + onWhat + "/" + id,
- {headers: {'Authorization': localStorage.getItem('Authorization')}}).toPromise();
- }
Advertisement
Add Comment
Please, Sign In to add comment