Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (Meteor.isClient) {
- Template.testing.events({
- 'click button': function(event, tpl) {
- event.preventDefault();
- var method = 'GET';
- var url = 'http://localhost:6543/test';
- var options = {
- headers: {'Content-Type': 'application/json'}
- }
- HTTP.call(method, url, options, function(error, result) {
- if (error) {
- console.log('ERRR');
- console.log(error);
- } else
- console.log('RESULT');
- console.log(result);
- });
- }
- });
- }
- if (Meteor.isClient) {
- Template.testing.events({
- 'click button': function(event, tpl) {
- event.preventDefault();
- var method = 'GET';
- var url = 'http://localhost:6543/test';
- var options = {
- headers: {'Content-Type': 'application/json'}
- }
- Meteor.call('APICall', method, url, options, function (error, result) {
- if (error) {
- console.log('CLIENT ERRR');
- console.log(error);
- } else {
- console.log('CLIENT RESULT');
- console.log(result);
- }
- });
- }
- });
- }
- if (Meteor.isServer) {
- Meteor.methods({
- APICall: function (method, url, options) {
- HTTP.call(method, url, options, function(error, result) {
- if (error) {
- console.log('SERVER ERRR');
- console.log(error);
- } else
- console.log('SERVER RESULT');
- console.log(result);
- });
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement