UNPKG

@pkyeck/storybook-addon-mock

Version:
20 lines 1.01 kB
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); } import { getBaseUrl } from './url'; export 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 = getBaseUrl(this.url); if (_url.search) { this.searchParams = Object.fromEntries(new URLSearchParams(_url.search)); } }