10 examples of 'local storage get item' in JavaScript

Every line of 'local storage get item' 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
51getItem(key) {
52 return this.state.data[key];
53}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

20getItem(key: string): any {
21 return this.data.get(key);
22}
4export function getStorage(key) {
5 const item = getItem(key);
6 try {
7 return JSON.parse(item);
8 } catch (e) {
9 return item;
10 }
11}
30getItem (key) {
31 let value = this.storage.getItem(key);
32
33 if (this.options.serialize) {
34 return this._decode(value);
35 }
36
37 return value;
38}
18async get (key) {
19 const value = this.store.getItem(key)
20 return typeof value === 'string' ? value : undefined
21}
196get(key) {
197 return this.storage.getItem(key);
198}
34getLocal(key: string): any {
35 const data = window.localStorage.getItem(key);
36 if (data) {
37 return JSON.parse(data);
38 } else {
39 return null;
40 }
41}
19getItem(key, callback){
20 this.data.get(key, ack => {
21 if(!ack.put){
22 callback('not_found')
23 } else {
24 callback(null, ack.put)
25 }
26 })
27}
134export 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}
28get(key) {
29 return localStorage.getItem(this.prefix + key);
30}

Related snippets