We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b0ede0f commit f564852Copy full SHA for f564852
src/utils/localStorage.js renamed to src/utils/localStorage.ts
@@ -1,12 +1,13 @@
1
-export function setWithExpiry(key, value, ttl) {
+export function setWithExpiry(key: string, value: any, ttl: number) {
2
const item = {
3
- value: value,
+ value,
4
expiry: new Date().getTime() + ttl
5
}
6
+
7
localStorage.setItem(key, JSON.stringify(item))
8
9
-export function getWithExpiry(key) {
10
+export function getWithExpiry(key: string) {
11
const itemString = window.localStorage.getItem(key)
12
if (!itemString) return null
13
0 commit comments