Closed NoahPerez closed 7 months ago
Yes, the digital product guide seems out of sync with the documentation. Besides missing mediaRequest
, there are other cases.
I think it is necessary to create a new app according to the docs:
pnpx create-medusa-app@latest --with-nextjs-starter
Then try to follow along with the Digital Products docs and fix the docs accordingly, for both the backend and storefront: Digital Products Documentation.
Meanwhile, a warning at the top of the page could be added to inform that the document is deprecated.
Thank you both for reporting this issue. Seems like medusaRequest
was renamed to medusaClient
in the Next.js storefront. Sorry for the inconvenience. Will look into updating the Next.js storefront code in the recipe
Preliminary Checks
Issue Summary
in the Docs it say , but medusaRequest seems that doesn't exist
Then, add in src/lib/data/index.ts Copy to Clipboard a new function that retrieves the product media of the product variant being viewed:
src/lib/data/index.ts
import { ProductMedia, } from "types/product-media" import { Variant } from "../../types/medusa"
// ... rest of the functions
export async function getProductMediaPreviewByVariant( variant: Variant ): Promise {
const {
product_medias,
} = await medusaRequest(
"GET",
/product-media
, { query: { variant_ids: variant.id, }, } ) .then((res) => res.body) .catch((err) => { throw err })return product_medias[0] }
Link to the Docs https://docs.medusajs.com/recipes/digital-products#preview-digital-product
How can this issue be resolved?
...
Are you interested in working on this issue?