Skip to content

Instantly share code, notes, and snippets.

@ShahirZain
ShahirZain / index.js
Created December 12, 2021 13:52
How to get QueryParams in modern JavaScript
export const getQueryParams = queryParams => {
const urlParams = new URLSearchParams(queryParams);
return Array.from(urlParams.entries()).reduce((acc, [key, value]) => {
acc[key] = value;
return acc;
}, {});
};