11ty / 11ty/fetch

Function passing not working?

Open
#67 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
166
Forks
21
PR merge metrics
No merged PRs in 30d

Description

I'm trying to do something sort of complicated on my site (basically work around #66) using the function passing capability, but it doesn't seem to be working for me. I simplified it down to a minimal form. I have this global data file cachetest.js:

import Fetch from "@11ty/eleventy-fetch"

export default async function() {
    return await Fetch(async () => {
        console.log("Cache miss")
        return {
            foo: "bar"
        }
    }, {
        requestId: "cachetest",
        duration: "1h"
    })
}

Each time I run it logs "Cache miss" to the shell output. Never does it seem to write anything to .cache. Have I done something wrong here?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal example in cachetest.js and the function-passing behavior exposed by @11ty/eleventy-fetch. Run it repeatedly while checking whether .cache is written and whether “Cache miss” appears each time. Done means the supplied function honors requestId and duration so repeated runs use the cached result.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.