"Advanced Method Boilerplate" Doesn't return a result?


#1

Maybe somebody could help me figure this out - my meteor method is not returning a result… I’m using the “Advanced Method Boilerplate” code:

import { Meteor } from 'meteor/meteor'

import { Suggestions } from './suggestions'

import _ from 'lodash'
import moment from 'moment'

export const addSuggestion = {
  name: 'suggestion.add',

  validate(args) {
    // Not sure what to do here yet... waiting to build this out later.
  },

  run(incommingSuggestion) {
    let currentUser = Meteor.user()

    if (!currentUser) {
      throw new Meteor.error("not-logged-in", "You're not logged-in, an account is required to submit a new idea.  Please login, or create an account")
    } else {
      let suggestion = _.extend(incommingSuggestion, {
        submittingUserId: currentUser._id,
        score: 0,
        personalScore: [],
        timestamp: moment().toDate(),
        evaluatedBy: []
      })

      console.log(suggestion)

      return suggestion
    }
  },

  call(args, callback) {
    const options = {
      returnStubValue: true,
      throwStubExceptions: true
    }

    Meteor.apply(this.name, [args], options, callback)
  }
}

Meteor.methods({
  [addSuggestion.name]: function (args) {
    addSuggestion.validate.call(this, args)
    addSuggestion.run.call(this, args)
  }
})

And the code to call it:

    addSuggestion.call(newSuggestion, (error, result) => {
      if (error) {
        console.log(error)
      } else {
        console.log(result)
      }
    })

I always get undefined in the console. Does anyone know why?