UNPKG

@openweb3-io/waas

Version:

WaaS API client and WaaS verification library

31 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IsomorphicFetchHttpLibrary = void 0; const http_1 = require("./http"); const rxjsStub_1 = require("../rxjsStub"); require("whatwg-fetch"); class IsomorphicFetchHttpLibrary { send(request) { let method = request.getHttpMethod().toString(); let body = request.getBody(); const resultPromise = fetch(request.getUrl(), { method: method, body: body, headers: request.getHeaders(), credentials: "same-origin" }).then((resp) => { const headers = {}; resp.headers.forEach((value, name) => { headers[name] = value; }); const body = { text: () => resp.text(), binary: () => resp.blob() }; return new http_1.ResponseContext(resp.status, headers, body); }); return rxjsStub_1.from(resultPromise); } } exports.IsomorphicFetchHttpLibrary = IsomorphicFetchHttpLibrary; //# sourceMappingURL=isomorphic-fetch.js.map