UNPKG

mframejs

Version:
54 lines 2.01 kB
Object.defineProperty(exports, "__esModule", { value: true }); var FetchClient = (function () { function FetchClient(config) { if (config === void 0) { config = {}; } this.config = config; this.setConfig(config); } FetchClient.prototype.setConfig = function (config) { if (config.defaultUrl) { this.config.defaultUrl = config.defaultUrl; } if (config.cache) { this.config.cache = config.cache; } if (config.credentials) { this.config.credentials = config.credentials; } if (config.headers) { this.config.headers = config.headers; } if (config.method) { this.config.method = config.method; } if (config.mode) { this.config.mode = config.mode; } if (config.redirect) { this.config.redirect = config.redirect; } if (config.referrer) { this.config.referrer = config.referrer; } }; FetchClient.prototype.getConfig = function () { return this.config; }; FetchClient.prototype.fetch = function (url, options) { var fetchUrl = this.config.defaultUrl ? this.config.defaultUrl + url : url; var fetchOptions = { body: options.body ? options.body : undefined, cache: options.cache || this.config.cache, credentials: options.credentials || this.config.credentials, headers: options.headers || this.config.headers, method: options.method || this.config.method, mode: options.mode || this.config.mode, redirect: options.redirect || this.config.redirect, referrer: options.referrer || this.config.referrer }; return fetch(fetchUrl, fetchOptions); }; return FetchClient; }()); exports.FetchClient = FetchClient; //# sourceMappingURL=fetchClient.js.map