-
-
Save ajb413/3b15101a0a7a845ed239de0824c2b78d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useAsyncEffect(async () => { | |
let borrowerData; | |
try { | |
borrowerData = JSON.parse(window.localStorage.getItem('borrowerData')); | |
borrowerData = borrowerData[market] || {}; | |
} catch(e) { | |
borrowerData = {}; | |
} | |
if ((!borrowerData.lastFetch || borrowerData.lastFetch < (Date.now() - 60 * 1000)) && market) { | |
const res = await fetch(`http://localhost:3000/borrowers/${market}`); | |
borrowerData = await res.json(); | |
borrowerData.lastFetch = Date.now(); | |
window.localStorage.setItem('borrowerData', JSON.stringify({ [market]: borrowerData })); | |
} | |
setBorrowers(borrowerData); | |
}, [web3, timer]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment