Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. if (Meteor.isClient) {
  2. Template.testing.events({
  3. 'click button': function(event, tpl) {
  4. event.preventDefault();
  5.  
  6. var method = 'GET';
  7. var url = 'http://localhost:6543/test';
  8. var options = {
  9. headers: {'Content-Type': 'application/json'}
  10. }
  11.  
  12. HTTP.call(method, url, options, function(error, result) {
  13. if (error) {
  14. console.log('ERRR');
  15. console.log(error);
  16. } else
  17. console.log('RESULT');
  18. console.log(result);
  19. });
  20. }
  21.  
  22. });
  23. }
  24.  
  25. if (Meteor.isClient) {
  26. Template.testing.events({
  27. 'click button': function(event, tpl) {
  28. event.preventDefault();
  29.  
  30. var method = 'GET';
  31. var url = 'http://localhost:6543/test';
  32. var options = {
  33. headers: {'Content-Type': 'application/json'}
  34. }
  35.  
  36. Meteor.call('APICall', method, url, options, function (error, result) {
  37. if (error) {
  38. console.log('CLIENT ERRR');
  39. console.log(error);
  40. } else {
  41. console.log('CLIENT RESULT');
  42. console.log(result);
  43. }
  44. });
  45. }
  46.  
  47. });
  48. }
  49.  
  50. if (Meteor.isServer) {
  51. Meteor.methods({
  52. APICall: function (method, url, options) {
  53. HTTP.call(method, url, options, function(error, result) {
  54. if (error) {
  55. console.log('SERVER ERRR');
  56. console.log(error);
  57. } else
  58. console.log('SERVER RESULT');
  59. console.log(result);
  60. });
  61. }
  62. });
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement