parse keywordsearchstring from url http://localhost:52717/ticketwizard/eventfeed/0/5868?keywordsearchstring=eventkeyword in javascript

Here's an example code snippet to parse the keywordsearchstring variable from the given URL:

index.tsx
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const keywordSearchString = urlParams.get('keywordsearchstring');
console.log(keywordSearchString); // outputs "eventkeyword"
222 chars
5 lines

This code extracts the query string from the URL using window.location.search. Then, it uses the URLSearchParams API to parse the query string and obtain a JavaScript object representing the parameters. Finally, it accesses the keywordsearchstring parameter using the get method of the URLSearchParams object.

gistlibby LogSnag