no http request to server ANGULAR

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



no http request to server ANGULAR



hello guys here is my likePost function


likePost(post){
let head = new Headers( 'Content-Type': 'application/json',
"Authorization":"JWT "+localStorage.getItem("token")

);
let requestOptions = new RequestOptions(headers: head);
// this.http.post(this.likeurl,requestOptions)

this.http.post(this.likeurl+post.id+'/like',requestOptions)



here is my post.html


<button mat-button (click)="likePost(post)">LIKE</button>



but when i clicked on my like button in the angular app i couldnt see any kind of requests by angular to my server
and when i checked it in myserver nothing has changed



BTW the link when once fired will create a like by that user in myserver for that angular should just browse it once and the like will be added





Possible duplicate of angular2: http post not executing
– jonrsharpe
Aug 12 at 13:50




1 Answer
1



You need to call subscribe on the observable,


subscribe


this.http.post(this.likeurl+post.id+'/like',requestOptions).subscribe((response)=>
console.log(response);
);






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS