I have a product-card snippet, but I need to make a request to the Shopify API to fetch some products and render them in the same product-card snippet. How can I do this since the API is one thing and the snippet is another?
Topic summary
A developer needs to fetch products from the Shopify API and render them using an existing product-card snippet. They’re uncertain how to integrate API calls with Liquid snippets.
Proposed Solution:
- Write JavaScript directly within the snippet file to make API requests
- Use the Shopify Product Admin API to retrieve either:
- A list of products
- A single product
- Reference the REST Admin API documentation for implementation details
Status: The question has received a technical approach but remains open for implementation.
You can write javascript inside the snippet file itself to make an api request. You can either retrieve a list of products or a single product using the product admin api.
See reference in rest admin api Shopify —> Product