MCPcopy
hub / github.com/microsoft/SandDance / httpLoader

Function httpLoader

docs/app/js/sanddance-app.js:109025–109030  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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() {

Callers 1

loaderFactoryFunction · 0.70

Calls 1

textMethod · 0.80

Tested by

no test coverage detected