Promise Support and misc refactor
#115 - Add promise support to fetchr
// Before
fetcher
.read('data_api_service')
.params({id: ###})
.end(function (err, data) {
// data is returned by `data_api_service`
});
//After
fetcher
.read('data_api_service')
.params({id: ###})
.end()
.then(function (result) {
// result.data is returned by `data_api_service`
});
#122 - Refactor service metadata
Metadata logic in fluxible-plugin-fetchr
has been moved into fetchr
itself. The usage is the same as before.
// callback
fetcher
.read('data_api_service')
.params({id: ###})
.end(function (err, data, meta) {
// meta will contain any headers returned by the `data_api_service`
});
// promise
fetcher
.read('data_api_service')
.params({id: ###})
.end()
.then(function (result) {
// result.meta will contain any headers returned by the `data_api_service`
});