0

I'm planning on create a get all item for local storage to pass in Indexed DB. I'm using Blazor WASM. This local storage code is from retrieve all localStorage items . I have this few error

Invalid expression [, syntax error value expected

'object' does not contain a definition for 'keys'

 private void allStorage()
{
   //error Invalid expression [
    var values = [],
        //error keys
        keys = Object.keys(localStore),
        i = keys.length;

    while (i--)
    {
        values.push(localStore.GetItem(keys[i]));
    }

    return values;
}
Hani
  • 21
  • 1
  • 12
  • 1
    You can only access local storage using JsInterop. I would suggest using a library like: https://github.com/blazored/LocalStorage – Kane May 20 '21 at 12:33
  • @Kane yes I am using `Blazored Localstorage NuGet` my localtorage code in razor (C#) & it works but I just problem on how to call get all item – Hani May 20 '21 at 23:53

1 Answers1

2

To get all items you may want to store all items as a single item - a json object. Once you have done that, you can get this single json object and extract all individual item values from it.