UNPKG

@beenotung/tslib

Version:
21 lines (20 loc) 712 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetch_retry = void 0; exports.fetch_no_cache = fetch_no_cache; function fetch_no_cache(url, method = 'GET') { const req = typeof Request === 'function' ? new Request(url) : url; const headers = new Headers(); headers.append('pragma', 'no-cache'); headers.append('cache-control', 'no-cache'); const init = { method, cache: 'no-cache', headers, }; return fetch(req, init); } const fetch_retry = (url, num_remain = 1, e) => num_remain <= 0 ? Promise.reject(e) : fetch(url).catch(e => (0, exports.fetch_retry)(url, num_remain - 1, e)); exports.fetch_retry = fetch_retry;