fetch-once
v3.0.0
Published
Ensure requests are only made once no matter how many times your application calls them
Downloads
4
Readme
Fetch-Once
Ensure requests are only made once no matter how many times your application calls them, support custom cache lengths.
options
- Supports all request options
{
cache: true|false|int, // default: true
successHandler: fn // For heavy processing of response only performed once
}
Example usage
// pendingRequests (singleton)
var requests = {};
// Component1.js
var fetchOnce = require('fetch-once');
fetchOnce(requests, {
url: 'http://google.com'
}).then(function (data) {
// use data in render
});
// Component2.js
var fetchOnce = require('fetch-once');
fetchOnce(requests, {
url: 'http://google.com'
}).then(function (data) {
// use data in render
});