Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let fetching = {};
- export default (url, options = {}) => {
- if (fetching[url]) {
- return Promise.reject(`Fetch responsibly, a fetch for the same url (${url}) is already in progress (options are ignored).`);
- }
- fetching[url] = true;
- return fetch(url, options).then(response => {
- fetching[url] = false;
- return response;
- });
- };
Add Comment
Please, Sign In to add comment