Every line of 'how to get data from localstorage in javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
256 function getLocalData(key) { 257 if (window.localStorage) { 258 return window.localStorage.getItem(key); 259 } 260 }
38 function getLocalStorage(key) { 39 return localStorage.getItem(key); 40 };
311 function getLocalStorage (currentControl, key) { 312 if (key in store) { 313 const stored = store[key]; 314 if (!stored) return undefined; 315 if (currentControl.type !== stored.type) return undefined; 316 if (currentControl.value !== stored.defaultValue) return undefined; 317 // console.log('CHECK CHECK', key, currentControl.value, stored.defaultValue) 318 return stored.value; 319 } 320 return undefined; 321 }
39 function getValueFromLocalStorage() { 40 if (typeof localStorage === "undefined") { 41 return null; 42 } 43 const storedValue = localStorage.getItem(key) || "null"; 44 try { 45 return JSON.parse(storedValue); 46 } catch (err) { 47 console.error(err); 48 } 49 return storedValue; 50 }
53 function GetFromLocalStorage(): LocalStorageAppContext | null { 54 const localStorageAppContextJson = localStorage.getItem(appContextKey); 55 56 if (localStorageAppContextJson) { 57 const localStorageAppContext = JSON.parse(localStorageAppContextJson); 58 59 return localStorageAppContext; 60 } 61 62 return null; 63 }
134 export function getStorageData(key) { 135 var item = null; 136 try { 137 if (window.localStorage) { 138 item = window.localStorage.getItem(key); 139 } 140 } catch (e) { 141 } 142 return item; 143 }
163 function getLocalStorageStr(key, defaultValue) { 164 return window.localStorage[key] || defaultValue; 165 }
117 function getLocalStorageItem(key) { 118 try { 119 return JSON.parse( 120 window.localStorage.getItem(key) 121 ); 122 } catch (e) { 123 return null; 124 } 125 }
11 function getLocalStorageObject() { 12 const localStorageObject = LocalStorageUtil.get(LOCAL_STORAGE_KEY); 13 if (localStorageObject != null) { 14 try { 15 return JSON.parse(localStorageObject); 16 } catch (e) { 17 return null; 18 } 19 } 20 return null; 21 }
9 export function loadFromLocalStorage (key) { 10 return window.localStorage.getItem(key) 11 }