Blame view

server/methods/utility/example.js 659 Bytes
36b159afd   Ryan Glover   Add server/method...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  /*
  * Methods: Utility - Example
  * Example of a method used for performing a function on the server.
  */
  
  // Example third-party API stub to call.
  // This should be deleted and is only here as an example.
  var chipotle = {
    getBurrito: function(burrito){
      return burrito;
    }
  }
  
  Meteor.methods({
    exampleUtilityMethod: function(argument){
      // Check the argument. Assuming an Object type here.
      check(argument, Object);
  
      // Perform the function.
      try {
        var apiCall = chipotle.getBurrito("Barbacoa");
        return apiCall;
      } catch(exception) {
        // If an error occurs, return it to the client.
        return exception;
      }
    }
  });