Revert "fetch refactoring"

This reverts commit 0122e9b456.
This commit is contained in:
Cory Dransfeldt 2023-03-15 04:49:30 -07:00
parent e7421c5803
commit e4ad42cd7f
No known key found for this signature in database
4 changed files with 27 additions and 27 deletions

View file

@ -1,11 +1,11 @@
const fetch = require('node-fetch')
const { AssetCache } = require('@11ty/eleventy-fetch')
const EleventyFetch = require('@11ty/eleventy-fetch')
module.exports = async function () {
const url = 'https://api.omg.lol/address/cory/statuses/'
const asset = new AssetCache('status_data')
if (asset.isCacheValid('1h')) return await asset.getCachedValue()
const status = await fetch(url).then((res) => res.json())
await asset.save(status, 'json')
const res = EleventyFetch(url, {
duration: '1d',
type: 'json',
})
const status = await res
return status.response.statuses[0]
}