cluster-request
v2.1.1
Published
A proxy to send requests within a kubernetes cluster
Downloads
60
Readme
cluster-request
A proxy module to send requests within a Kubernetes cluster of microservices
Installation
npm i --save cluster-request
Default Request Options
method: 'GET',
json: true,
gzip: true
Usage
const ClusterRequest = require('./lib');
const log = console;
const cluster = new ClusterRequest({
log,
defaultPort: 80,
defaultReqOptions: {
headers: {},
json: true,
gzip: false,
},
});
cluster
.request('echo.jsontest.com', '/a/b/c/d/e/1/data/some_data', {})
.then((response) => {
console.log('Status Code: ', response.statusCode);
console.log('Body: ', response.body);
cluster
.validateResponse(response)
.then((data) => {
console.log('Response data: ', data);
})
.catch((err) => {
console.log('Error: ', err);
});
})
.catch((err) => {
console.log('Error: ', err);
});
Source: demo.js