Skip to content

Commit

Permalink
feat: leverage 11ty fetch plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Brennvo committed Jan 9, 2023
1 parent 5d848b8 commit fdfd6aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules
/public
.cache
.vscode
person-website.code-workspace
8 changes: 5 additions & 3 deletions src/_data/joke.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const EleventyFetch = require('@11ty/eleventy-fetch');
const WORKER_URL = 'https://daily-joke.catherby.workers.dev/';

async function getJoke() {
try {
const res = await fetch(WORKER_URL);
const data = await res.json();
const { setup, delivery } = data;
const { setup, delivery } = await EleventyFetch(WORKER_URL, {
duration: '1d',
type: 'json',
});
return { setup, delivery };
} catch (e) {
console.error(e);
Expand Down

0 comments on commit fdfd6aa

Please sign in to comment.