"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var httpFetcher_1 = require("./httpFetcher");
require("isomorphic-fetch");
var AuthHttpFetcher = (function () {
function AuthHttpFetcher(uri, authToken) {
var _this = this;
this.myFetch = function (input, init) {
Iif (init === void 0) { init = {}; }
init.body = init.body || {};
init.body.headers = init.body.headers || {};
init.body.headers['authorization'] = _this.authToken();
return fetch(input, init)
.then(function (response) {
Iif (response.status === 401) {
return new Response({
ok: false,
});
}
return response;
});
};
this.httpFetcher = new httpFetcher_1.default({ uri: uri, fetch: this.myFetch });
this.authToken = authToken;
}
AuthHttpFetcher.prototype.request = function (operation) {
return this.httpFetcher.request(operation);
};
return AuthHttpFetcher;
}());
exports.default = AuthHttpFetcher;
//# sourceMappingURL=authHttpFetcher.js.map |