UNPKG

@trezor/connect

Version:

High-level javascript interface for Trezor hardware wallet.

29 lines (28 loc) 817 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.httpRequest = void 0; const tslib_1 = require("tslib"); const cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch")); const assetUtils_1 = require("./assetUtils"); const httpRequest = async (url, type = 'text', options) => { const init = { ...options, credentials: 'same-origin' }; const response = await (0, cross_fetch_1.default)(url, init); if (response.ok) { if (type === 'json') { const txt = await response.text(); return JSON.parse(txt); } if (type === 'binary') { return response.arrayBuffer(); } return response.text(); } throw new assetUtils_1.HttpRequestError(response); }; exports.httpRequest = httpRequest; //# sourceMappingURL=assets-browser.js.map