2.0.1 • Published 7 years ago
service-pilot v2.0.1
##Exchange Services
Initialize the exhcange services class with an array of services to be registered
e.g:
const ExchangeServices = require('exchange-service');
const services = ['books', 'emails'];
const exchangeService = new ExchangeServices(services);
let options = {};
if (['PUT', 'POST'].includes(req.method.toUpperCase())) {
options.body = req.body;
options.json = true;
}
servicePilot.requestResource('books', '/', { 'header': 'value' }, Object.assign({
method: req.method,
}, options))
.then((data) => {
res.response = data.body;
res.statusCode = data.statusCode;
next();
})
.catch((err) => {
next(err);
});