Skip to content

[Bug]: Documentation example in digital products is forcing cache #13687

@gonalc

Description

@gonalc

What Medusa version and documentation are you using?

v2

Preliminary Checks

Issue Summary

Following the docs to implement the digital products I found out the last step is not working properly.

When retrieving the list of digital products a customer has bought, the cache is forced so it never hits the API, therefore the digital products don't appear in the screen.

The mentioned file is the one placed under src/lib/data/digital-products.ts.

How can this issue be resolved?

  1. Go to the mentioned file in src/lib/data/digital-products.ts.
  2. This can be solved by just changing the cache param in the api call from force-cache to no-cache or no-store.
  3. The function would look like this:
export const getCustomerDigitalProducts = async () => {
  const headers = {
    ...(await getAuthHeaders()),
  }

  const next = {
    ...(await getCacheOptions("products")),
  }
  const { digital_products } = await sdk.client.fetch<{
    digital_products: DigitalProduct[]
  }>(`/store/customers/me/digital-products`, {
    headers,
    next,
    cache: "no-cache",
  })

  return digital_products as DigitalProduct[]
}

Are you interested in working on this issue?

  • I would like to fix this issue

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions