Skip to main content

DeleteFromWebStorage

Description

Deletes the key value pair stored in the browser web storage for the given key.

Syntax

// Deletes a key from application specific storage.
MFiles.DeleteFromWebStorage(keyName);

Parameters

NameTypeDescription
keystringThe web storage key.

Return type

TypeDescription
Promise < void >Method does not return a value

Example

This sample demonstrates the use of M-Files API functions to interact with web storage: it writes "Sample Value" to storage with the key "testKey", reads it back, logs the value to the console, and finally deletes the entry from web storage.

note

Values written to web storage must be string values, because they are internally serialized into string values.


// Called when the UI Extension starts
async function OnNewShellUI(shellUI) {

// Write to web storage some value
await MFiles.WriteToWebStorage( "testKey", "Sample Value" );

// Read the value from the web storage
const storedValue = await MFiles.ReadFromWebStorage( "testKey" );

// Outputs: "Sample Value"
console.log( storedValue );

// Remove key from the storage.
await MFiles.DeleteFromWebStorage( "testKey" );

}