Blog , Blog Details System in React Js / How to get Slug from URL in React JS
Copy Below Code
View As A Text File
Show Text Only
Show API
Edit Code
======= Blog / Products & Details Page System ======
1) In Blogs.js file
<Link to={{pathname: `blog/${item.post_slug}`, query: { slug: item.post_slug }}}>Read More <i class="fas fa-long-arrow-alt-right"></i></Link>
Note: "query" array sending an object like a Props. We can access that object as props in next file
2) In Blog-Details.js
const slug=this.props.match.params.slug; // By URL
You get that object as props and get your Slug. Now you may send an Axious request to get that slug details