What do you want to save?
Add Code snippet
New code examples
-
Other 2021-11-21 22:10:24
save in local storage with expiration
function getWithExpiry(key) { const itemStr = localStorage.getItem(key) // if the item doesn't exist, return null if (!itemStr) { return null } const item = JSON.parse(itemStr) const now = new Date() // compare the expiry time of the item with th... Add solution -
Javascript 2021-11-19 22:15:22
como ler um arquivo json com javascript
const { read } = require('fs') const readJsonFile = file => { if (file.split('.')[file.split('.').length - 1] !== 'json') return {} const fileContent = read(file) if (!fileContent) return {} return JSON.parse(fileContent) } readJsonFile('pac... Add solution
Best helpers
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5