Nerdiest Political Manifesto

    restful-promise

    1.0.5 • Public • Published

    restful-promise NPM version

    Promise-based RESTful API for node applications.

    $ npm install restful-promise
    

    Hybrid of rest-interface and simple-promise libraries - basically a RESTful application interface that operates on promises.


    Code Samples

    Your best resource is the docs for the two parent libraries, but here are some quick code samples to help you get started.

    Define your API

    API definition stays exactly the same as it was in rest-interface...

    var api = require('restful-promise');
    module.exports = api({
        get: function (done, all, your, args) {
            // "done" signals that your async behavior
            // has completed.
            done(some, values);
        },
        post: ..,
        put: ..,
        delete: ..
    });
    

    Using your API

    ... the difference is that REST actions are now promises!

    var mycoolapi = require('mycoolapi');
    var out = mycoolapi.put('some', 'args')
        .then(function (result) {
            // do something with result of promise.
        })
        .error(function (err) {
            // do something if an error occurred.
        });
    // Value of "out" will be the return value of the put operation.
    

    Install

    npm i restful-promise

    DownloadsWeekly Downloads

    7

    Version

    1.0.5

    License

    MIT

    Last publish

    Collaborators

    • cobbdb