* HTTP request handler factory. * @param {function} fetch - The Fetch API method. * @return {function} - An http loader with the following signature: * param {string} url - The url to request. * param {object} options - An options hash. * return {Promise} - A promise that resolves to the
(fetch)
| 109023 | * param {object} options - An options hash. |
| 109024 | * return {Promise} - A promise that resolves to the file contents. |
| 109025 | */ function httpLoader(fetch) { |
| 109026 | return fetch ? async function(url, options) { |
| 109027 | const opt = (0, _vegaUtil.extend)({}, this.options.http, options), type = options && options.response, response = await fetch(url, opt); |
| 109028 | return !response.ok ? (0, _vegaUtil.error)(response.status + "" + response.statusText) : (0, _vegaUtil.isFunction)(response[type]) ? response[type]() : response.text(); |
| 109029 | } : httpReject; |
| 109030 | } |
| 109031 | /** |
| 109032 | * Default http request handler that simply rejects. |
| 109033 | */ async function httpReject() { |