var config = ('../config/config_'+process.env.NODE_ENV+'.conf.js');
/*
config = {
restfulAPI: {
protocol: 'http:'
hostname: 'api.domain.com',
port: 4000
}
}
*/
var jRestClient = require('json-rest-c');
var client = jRestClient(config.restfulAPI);
client.get('url/to/get', (resp, respStatusCode, respHeaders) => {
...
}).on('error', (err) => {
...
});
$ npm install json-rest-c --save
- Support all Restful methods or custom method;
- Allows https connection;
- Allows simple HTTP basic authentication;
- Errors easily handling.
constructor(options)
with options
of:
- resJSON <Boolean>
- protocol <String>
- hostname <String>
- port <Number>
- headers <Object>
- auth <String>
- agent <Object>
- timeout <Number>