fetch refactoring
This commit is contained in:
parent
9a5431cffa
commit
0122e9b456
4 changed files with 27 additions and 27 deletions
|
@ -1,12 +1,12 @@
|
|||
const EleventyFetch = require('@11ty/eleventy-fetch')
|
||||
const fetch = require('node-fetch')
|
||||
const { AssetCache } = require('@11ty/eleventy-fetch')
|
||||
|
||||
module.exports = async function () {
|
||||
const url = 'https://utils.coryd.dev/api/webmentions'
|
||||
const res = EleventyFetch(url, {
|
||||
duration: '1d',
|
||||
type: 'json',
|
||||
})
|
||||
const webmentions = await res
|
||||
const asset = new AssetCache('webmentions_data')
|
||||
if (asset.isCacheValid('1h')) return await asset.getCachedValue()
|
||||
const webmentions = await fetch(url).then((res) => res.json())
|
||||
await asset.save(webmentions, 'json')
|
||||
return {
|
||||
mentions: webmentions.children,
|
||||
}
|
||||
|
|
Reference in a new issue