/** * Request object - singleton instance model */ export default class Request { // Static instance private static _instance: any; private _url: URL; constructor(){ this._url = new URL(window.location.href); } /** * Get a singleton version of this request */ public static get instance() { if (!this._instance) { this._instance = new Request(); } return this._instance; } /** * Get the url object for the current request */ get url(): URL { return this._url; } /** * Get the request params as object */ get params(): any { let searchParams = this._url.searchParams; let params: any = {}; searchParams.forEach((value: any, key: any) => { params[key] = value; }); return params; } }