diff --git a/app/backend/GetLocalStorage.ts b/app/backend/GetLocalStorage.ts index e838f74..487413f 100644 --- a/app/backend/GetLocalStorage.ts +++ b/app/backend/GetLocalStorage.ts @@ -1,16 +1,19 @@ // getLocalStorageData.ts +// Function to retrieve all items from localStorage export const getAllLocalStorageItems = (): Record => { - const allData: Record = {}; + const allData: Record = {}; // Object to hold key-value pairs from localStorage + + // Check if localStorage is available if (typeof localStorage !== 'undefined') { - for (let i = 0; i < localStorage.length; i++) { - const key = localStorage.key(i); - if (key) { - const value = localStorage.getItem(key); - allData[key] = value; + // Iterate through all localStorage keys + for (let i = 0; i < localStorage.length; i++) { + const key = localStorage.key(i); // Get the key at the current index + if (key) { + const value = localStorage.getItem(key); // Retrieve the value associated with the key + allData[key] = value; // Store the key-value pair in the allData object + } } - } } - return allData; - }; - \ No newline at end of file + return allData; // Return the object containing all localStorage items +};