Created
February 9, 2021 14:42
-
-
Save nsrCodes/f9b95c69c08a28cfc7ed55cb2975966f to your computer and use it in GitHub Desktop.
General Utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { toast } from "react-toastify"; | |
const copyToClipBoard = (textToCopy, prompt) => { | |
prompt = prompt || "Copied to clipboard!" | |
navigator.clipboard.writeText(textToCopy) | |
.then(() => { | |
toast.info(prompt) | |
}, (err) => { | |
console.error('Could not copy text: ', err); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getQueryParamsAsMap() { | |
let queryParams={}; | |
var params = new URLSearchParams(window.location.search); | |
params.forEach((value, key) => {queryParams[key] = value}) | |
return queryParams | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case of query params with no value, eg:
example.com/?code
, thequeryParams
will be{"": "code"}
This means it isn't a query param with no value but rather a query param with no key.