rest-proxy

0.0.9 • Public • Published

rest-proxy

is a simple REST API client

install

$ npm install rest-proxy

use

// require nad configure the proxy
var my-api = require('rest-proxy').create({
    baseUrl:            "example.com/api/",
    isSSL:              true,
    authentication: {
        type: "basic",
        defaultCredentials: {
            user:       "admin-user",
            password:   "admin-pass"
        }
    }, 
    services: {
        getMyResources: {
          method: "get",
          url: "myresources",
          success: 200
        },
        getMyresourceById: {
          method: "get",
          url: "myresources/{id}",
          success: 200
        }
    }
});


// call a service (in this case GET example.com/api/myresources/101)
my-api.invoke("getMyresourceById", {id:101}, null, function(err, res_body, res_details) {
    // do something with the received data
});

##license ISC

Readme

Keywords

none

Package Sidebar

Install

npm i rest-proxy

Weekly Downloads

0

Version

0.0.9

License

ISC

Last publish

Collaborators

  • aorlic