Last active
July 5, 2016 19:21
-
-
Save jp26jp/503d409c152752fe1d5b1b209dea9fad to your computer and use it in GitHub Desktop.
Remove all stored keys in Ecwid
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
var keyNames = []; | |
// function to delete each key from storage one by one | |
deleteAllStorageData = function (array){ | |
for (i=0; i < array.length; i++) { | |
$.ajax({ | |
url: 'https://app.ecwid.com/api/v3/' + storeId + '/storage/' + array[i] + '?token=' + accessToken, | |
type: 'DELETE' | |
}) | |
} | |
console.log('DELETED'); | |
getStorageKeys(); | |
} | |
// fill in keyNames array with all existing keys | |
getStorageKeys = function(){ | |
EcwidApp.getAppStorage(function(allKeys) { | |
for (i=0; i < allKeys.length; i++) { | |
keyNames.push(allKeys[i].key); | |
} | |
// print out all key names in storage | |
console.log(keyNames); | |
if (keyNames.length > 0) { | |
deleteAllStorageData(keyNames); | |
} else { | |
return; | |
} | |
}) | |
}; | |
getStorageKeys(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment