Creates a new fetchr plugin instance with the following parameters:
options
: An object containing the plugin settingsoptions.req
(required on server): The request object. It can contain per-request/context data.options.xhrPath
(optional): The path for all requests. Will be ignored serverside.options.xhrTimeout
(optional): Timeout in milliseconds for all requestsoptions.corsPath
(optional): Base CORS path in case CORS is enabledoptions.context
(optional): The context objectoptions.contextPicker
(optional): The context predicate functions, it will be applied to lodash/object/pick to pick values from context objectoptions.contextPicker.GET
(optional): GET predicate functionoptions.contextPicker.POST
(optional): POST predicate function
register a service with fetchr
var Fetcher = require('fetchr');
Fetcher.registerFetcher(myDataService);
getter for a service by resource
var Fetcher = require('fetchr');
var myDataService = {
resource: 'serviceResource',
read: function () {}, // custom read logic
};
Fetcher.registerFetcher(myDataService);
Fetcher.getFetcher('serviceResource'); // returns myDataService
getter for fetchr's express/connect middleware.
var Fetcher = require('fetchr'),
express = require('express'),
app = express();
app.use('/myCustomAPIEndpoint', Fetcher.middleware());
Call the read method of a service.
Call the create method of a service.
Call the update method of a service.
Call the delete method of a service.
Returns metadata for all service calls in an array format. The 0 index will be the first service call.
Update the options of the fetchr instance.