fetch-once

3.0.0 • Public • Published

Fetch-Once Circle CI

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
});
 

Readme

Keywords

none

Package Sidebar

Install

npm i fetch-once

Weekly Downloads

1

Version

3.0.0

License

ISC

Last publish

Collaborators

  • alexmeah