'how to get specific data using Codeigniter 4 and nextjs
I am trying to show only those services which have the company id of which company I click on
<Link href={`/store/Main?id=${company.id}`} >
<a className="ps-btn">Visit Store</a>
</Link>
this is the code of the next page I am redirecting the user to, and this is the code for getting the service Data
const router = useRouter();
var { id } = router.query;
useEffect(() => {
if (
router.query.id !== undefined &&
router.query.id != null &&
router.query.id > 0
) {
id = router.query.id;
getServiceById();
}
}, [router.query]);
const getServiceById = async () => {
const response = await axios.get(
`http://localhost:8080/services?company_id=${id}`
);
};
and this is how I am retrieving data
{services.map((service) => (
<div className="ps-product ">
<div className="ps-product__thumbnail">
<img
src="/static/img/vendor/store/vendor-150x150.jpg"
alt="martfury"
/>
</div>
<div className="ps-product__container">
<Link href="/shop">
<a className="ps-product__vendor">
<b>Service Name:</b> {service.service_name}
</a>
</Link>
<div className="ps-product__content">
<b>Service By:</b> {service.company_name}
<div className="ps-product__rating">
<Rating />
<span>02</span>
</div>
<b>Time Duration:</b> {service.time_duration}
</div>
</div>
<hr />
</div>
))}
Now what I want is that when I click on visit store it should redirect to the next page and show only the services of that specific company ID but it just shows all the services it might be the backend but I do not really know a lot of code igniter 4 so any help would be appreciable
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
