Search code examples
node.jses6-promisewit.ai

Wit.ai Promises Issue


Using Wit, its calling a custom action, but it doesnt look like the promise is being returned by my function call stack, and I cant see why

https://gist.github.com/mark-stephenson-/e0200233663b2cf1ce1d0a5a33559372

The error I get in the console is:

Oops! Got an error from Wit: TypeError: Cannot read property 'then' of undefined at /usr/local/workspace/nodeapps/levelup/index.js:130:9 at Object.activate_schedule (/usr/local/workspace/nodeapps/levelup/index.js:128:12) at /usr/local/workspace/nodeapps/levelup/node_modules/node-wit/lib/wit.js:121:36 at process._tickCallback (internal/process/next_tick.js:103:7)

Ive tried wrapping the LevelUp.set_activation_state function in a promise and returning that, but then the function then doesnt call at all.


Solution

  • You need to return this.get_user() from inside LevelUp.prototype.set_activation_state