UNPKG

storybook-addon-mock

Version:
26 lines (25 loc) 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Request = Request; var _url2 = require("./url"); function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function Request(input) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (_typeof(input) === 'object') { this.method = options.method || input.method || 'GET'; this.url = input.url; this.body = options.body || input.body || null; this.signal = options.signal || input.signal || null; } else { this.method = options.method || 'GET'; this.url = input; this.body = options.body || null; this.signal = options.signal || null; } var _url = (0, _url2.getBaseUrl)(this.url); if (_url.search) { this.searchParams = Object.fromEntries(new URLSearchParams(_url.search)); } }