Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yudapc/cc4fe1b0697af542e6d62c29dfd669d7 to your computer and use it in GitHub Desktop.
Save yudapc/cc4fe1b0697af542e6d62c29dfd669d7 to your computer and use it in GitHub Desktop.
Javascript
// Object to query string
params = { keyword: 'test', startDate: '20-02-2022' };
urlParams = new URLSearchParams(params).toString(); //"keyword=test&startDate=20-02-2022"
// Query string to Object
search = "keyword=test&startDate=20-02-2022"
queryParams = new URLSearchParams(search)
getParams = Object.fromEntries(queryParams);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment