mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-03-10 14:13:19 +00:00
18 lines
481 B
TypeScript
18 lines
481 B
TypeScript
export function getLocalStorage(key: string) {
|
|
try {
|
|
const item = localStorage.getItem(key);
|
|
return item ? JSON.parse(item) : null;
|
|
} catch (error) {
|
|
console.error(`Error reading from localStorage key "${key}":`, error);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export function setLocalStorage(key: string, value: any) {
|
|
try {
|
|
localStorage.setItem(key, JSON.stringify(value));
|
|
} catch (error) {
|
|
console.error(`Error writing to localStorage key "${key}":`, error);
|
|
}
|
|
}
|