Created
January 26, 2021 20:43
-
-
Save Dinir/a72b0f35f074c2cf1de3351aeff7f3c1 to your computer and use it in GitHub Desktop.
Copy whole local storage to import it somewhere else.
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
const replaceStorage = doubleStringifiedStorage => { | |
// copy storage with `copy(JSON.stringify(JSON.stringify(window.localStorage)))` | |
window.localStorage.clear() | |
const imported = JSON.parse(doubleStringifiedStorage) | |
for (const n in imported) { | |
localStorage.setItem(n, imported[n]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment