I currently doing a react app, I have to display the product image for each product, the product image is set as a ProductImagesID. To get the product image ID it needs to call an API.So I try to call directly in "src", but I don't know to replace the product. id and imageID with the data from the query to make it dynamic to show the photos for the specific product. Plz help me on how make the api in the src dynamic. With this i can learn somethings new to improve my knowledge. Thanks in Advance.
This how I try to call the API directly in the src
This the How the Productimage API with the productID and the ImageID.
This is the ProductImages are set in array of ID
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/15.0.1/react-dom.min.js"></script>
<div>
<div className="wrapper">
<div className="section latest-offers">
<Container>
<Row xs="1" sm="2" md="3">
{res.data.Result.slice(0, 3).map((product) => {
return (
<Col key={product.ID} xm="12" md={{ size: "3", offset: 1 }}>
<Card className="card-product card-plain d-flex flex-column p-3 flex-md-row flex-sm-column">
<div className="card-image p-2 ">
<img
className=""
alt={product.Name}
src="/api/v1/ProductFile/?productID={610a454ad51ba524b7f949f9}/?get=Product/?imageID={610a4582d51ba524b7f949fa}"
/>
<CardBody>
<div className="card-description font-weight-normal">
<CardTitle tag="h5">{product.Name}</CardTitle>
</div>
<div className="price">
<span className="mr-1">
<strong>
RM
{product.Price}
</strong>
</span>
</div>
</CardBody>
</div>
</Card>
</Col>
);
})}
</Row>
</Container>
</div>
</div>
</div>


