1.0.0 • Published 7 years ago

ah-bluebird-plugin v1.0.0

Weekly downloads
3
License
-
Repository
github
Last release
7 years ago

Installation

npm install ah-bluebird-plugin --save or yarn add ah-bluebird-plugin

Install plugin using instructions from https://www.actionherojs.com/docs/core/#plugins

Now try returning a promise inside of an action! The promise's result will be set at data.result and the request completed. If anything lands in the .catch(err) method, it'll pipe through AH's error formatter.

Example Action:

var Bluebird = require('bluebird');

exports.promiseExample = {
  name: 'promiseExample',
  description: 'I am an example of an action returning a promise',
  outputExample: {
    result:"hello world!",
    action:"promiseExample",
    serverInformation:Object,
    requestDuration:5,
  },
  inputs: {},

  run: function (api, data, next) {
    return new Bluebird.Promise(function(resolve, reject){
      resolve('hello world!');
    })
  }
}