Removes one or more items from the storage area.
Syntax
chrome.storage.<storageType>.remove(keys,callback);
<StorageType
> will be one of the writable storage types — storage.sync
or storage.local
.
Parameters
keys
- A string, or array of strings, representing the key(s) of the item(s) to be removed.
callback Optional
- A callback function that is run when the operation completes. The callback takes no arguments. If the operation failed,
runtime.lastError
is set.
Browser compatibility
Examples
Remove a single item, callback version:
// callback to remove() just checks for errors function onRemoved() { if (chrome.runtime.lastError) { console.log(chrome.runtime.lastError); } else { console.log("OK"); } } chrome.storage.local.remove("kitten", onRemoved);
Remove multiple items, callback version:
// callback to remove() just checks for errors function onRemoved() { if (chrome.runtime.lastError) { console.log(chrome.runtime.lastError); } else { console.log("OK"); } } chrome.storage.local.remove(["kitten", "grapefruit"], onRemoved);
Remove single item, promise version:
function onRemoved() { console.log("OK"); } function onError(e) { console.log(e); } var removeKitten = browser.storage.remove("kitten"); removeKitten.then(onRemoved, onError);
Example add-ons
Document Tags and Contributors
Tags:
Contributors to this page:
wbamberg,
chrisdavidmills
Last updated by:
wbamberg,