0.2.0 • Published 9 years ago
jimenez-http-communication v0.2.0
jimenez-http-communication
It provides js classes to make http calls
## Install
$ npm install jimenez-http-communication
##Content
##Usage
###serverInfo Creates a url to a server using protocol, domain name and optionally port.
####Example
var jhc = require('jimenez-http-communication');
var serverInfo = jhc.serverInfo("https", "localhost", 5984);
console.log(serverInfo.getUrl());
output:
"https://localhost:5984"
###endPoint
Creates the uri part for an endpoint. Its constructor receives a configuration object with the following properties:
####Example
var jhc = require('jimenez-http-communication');
var config = {
uri: "contribuyentes/:id/:name",
urlParams: { rev: 12345, tax: 18.3 },
routeParams: { id: "abcd", name: "test" }
};
var ep = jhc.endPoint(config);
console.log(ep.getUrl());
output:
"contribuyentes/abcd/test?rev=12345&tax=18.3"
###request
Returns a Q promise based on endPoint and serverInfo objects.
####Example
var jhc = require('jimenez-http-communication');
var request = jhc.request();
var promise = request.getPromise(serverInfo, endPoint);