'How to get item from backend after clicking on the url
I build a simple store website. Currently, I have built a home page where I have a list of products, after clicking on a specific product, it takes us to the page of that product and displays its details.Everything works fine because on the homepage I am transferring the data of that particular product to its detail page by state. Its looks like:
<Link
to={"/" + item.categoryModel.cateGoryName + "/" + item.product_id}
state={{ product_details: item }}
>
<Info>
<Title>{item.shortName}</Title>
<Desc>{item.shortDesc}</Desc>
<Price>{item.newPrice},00zł</Price>
</Info>
</Link>
Also I build url for specific product.
For example:
- HomePage:
"/" - Categories:
"/computers" - Product:
"/computers/1"
But when I type "/computers/1" without navigating to a specific product through the home page, state of course is Null. Can anyone tell me how to get a specific product from the backend without using state. I use for frontend Reactjs and Springboot for backend.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
