Guest User

http.get and http.post do not work

a guest
May 26th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. var JSONObject = {"latitude": "" + lat, "longitude": "" + lng};
  2.  
  3. console.log("Posting: " + JSON.stringify(JSONObject));
  4. let headerOptions: any = { 'Content-Type': 'application/json' };
  5. let headers = new Headers(headerOptions);
  6.  
  7. this.http.get("http://192.168.1.2:8080/location/new1/")
  8. .map((response: Response) => {
  9. console.log('Response is: ' + response);
  10. })
  11. .catch((this.handleErrorObservable));
  12.  
  13. this.http.post("http://192.168.1.2:8080/location/new/", JSON.stringify(JSONObject), new RequestOptions({ headers: headers }))
  14. .map((response: Response) => {
  15. console.log('Response is: ' + response);
  16. })
  17. .catch((this.handleErrorObservable));
Add Comment
Please, Sign In to add comment