Add error handling to public data fetching

This commit is contained in:
Max Goodhart
2020-06-21 21:13:09 -07:00
parent c25e5d5f59
commit ebcc0c8b2a

View File

@@ -14,9 +14,14 @@ export async function* pollPublicData() {
const publicDataURL = 'https://woke.net/csv'
const refreshInterval = 5 * 60 * 1000
while (true) {
let data
try {
const resp = await fetch(publicDataURL)
const text = await resp.text()
const data = await csv().fromString(text)
data = await csv().fromString(text)
} catch (err) {
console.warn('error loading stream data', err)
}
yield filterLive(data)
await sleep(refreshInterval)
}