title: How do I get the return value from a meteor method call?
body: <p>I have a meteor method defined on the client side using the pattern described here <a href="https://guide.meteor.com/methods.html#advanced-boilerplate" rel="nofollow noreferrer">https://guide.meteor.com/methods.html#advanced-boilerplate</a></p>
  
  <pre><code>
  // files.collection.js
  
  import { Meteor } from 'meteor/meteor';
  import { Mongo } from 'meteor/mongo';
  import SimpleSchema from 'simpl-schema';
  
  export const mediaFiles = new Mongo.Collection('media_files')
  
  export const method_InsertFile = {
      name: 'media_file.insert',
  
      // Factor out validation so that it can be run independently (1)
      validate(args) {
          console.log('call validation: ', args)
          new SimpleSchema({
              title: { type: String },
              filename: { type: String },
          }).validate(args)
      },
  
      // Factor out Method body so that it can be called independently (3)
      run({ filename, title }) {
          let inserted_object = { title, filename }
          mediaFiles.insert(inserted_object)
          return inserted_object // object of interest
      },
  
      call(args, callback) {
          console.log('call call method: ', args)
          const options = {
              returnStubValue: true,     // (5)
              throwStubExceptions: true  // (6)
          }
          Meteor.apply(this.name, [args], options, callback);
      }
  };
  
  if (Meteor.isServer) {
      Meteor.methods({
          // Actually register defined method with Meteor's DDP system
          [method_InsertFile.name]: function (args) {
              method_InsertFile.validate.call(this, args);
              method_InsertFile.run.call(this, args);
          },
      });   
  }
  </code></pre>
  
  <p>The method is being called as shown below</p>
  
  <pre><code>
  import { method_InsertFile } from '../api/files.collection';
  
  method_InsertFile.call(data, (err, res) =&gt; {
      if (err) console.log("Return err ", err)
      else {
          console.log('result: ', res)
      }
  })
  </code></pre>
  
  <p>I want to retrieve the object <code>inserted_object</code> at the end of the method call. I have tried returning a promise from within the <code>call</code> block of the method definition like this</p>
  
  <pre><code>return new Promise((resolve, reject) =&gt; {
      Meteor.apply(this.name, [args], options, (err, res) =&gt; {
          resolve(res)
      });
  })
  </code></pre>
  
  <p>but <code>result</code> returns <code>undefined</code>.</p>
  
  <p>Any pointers as to whether this is possible and how to accomplish it is appreciated.</p>