fetching all product images in commerce.js

289 views Asked by At

Hi! I'm building an e-commerce using React + Commerce.js.

I'm facing this issue: when I fetch (using commerce.products.list()) the product object with all its specs (name, price, description, image, etc...), all the image properties are related to the main image. However, on commerce.js you can upload several images per product, and I want to fetch all these images to create a Product Details page where you can browse through the different images.

Do you know how to do this?

Note: I read something about creating 'assets' and uploading images from the CLI, but if commerce.js allows you to create your store and several images per product, isn't there a way to access these already uploaded images through the API instead of having to re-upload as assets?

Thanks!!

1

There are 1 answers

0
Syzygeezus On

If you have already uploaded your images for your product, you can retrieve a collection of uploaded assets by using product.assets :)