The problem is - (trying to solve to problem of clicking on one article from a list of articles to then direct the user to that particular article to read) need to render a new page from an API call using the slug. The AllPosts page lists different articles. It requires a clickable link on the image in the list of articles to direct to the OnePost page that has the article on it, using data from the API. I have started on the BlogCard component where I use a Link component that wraps around the Title and Image from the article list. The Link component has the destination as {/posts/${slug}}>. the next part is trying to manage the routing on the App.js page, or if there is a more effective solution to this for the desired result(or If someone chooses a better way to do this). and finally, on the OnePost page (that the article is written on) I have started to make the API call with the intention of making it the same as the AllPost component(using AXIOS with graphQL schema), so far with little success. the OnePost page will display the article title and cover image. I have included a sandbox link to follow. And have left a commented-out code so it's not broken. Where it's at It will display the list of articles on the AllPosts page taken from the API data. Thanks so much in advance, I hope this all makes sense, any help or direction would be much appreciated.............. Thanks again - Python-Pirate 🐍🏴☠️😃...................
sandbox link -----> https://codesandbox.io/s/2-1-23-react-slug-link-3ncqli?file=/src/components/BlogCard.js
import React from "react";
import { Link } from "react-router-dom";
import "./styles.css";
const BlogCard = ({ coverPhoto, title }) => {
return (
<div className="card">
<Link to={`/posts/${slug}`}>
<h2>{title}</h2>
<img
src={coverPhoto ? coverPhoto.url : null}
alt=""
height={200}
width={200}
></img>
</Link>
</div>
);
};
export default BlogCard;
import React from "react";
import { useQuery } from "react-query";
import axios from "axios";
const endpoint =
"";
const QUERY = `
{
posts {
id
title
slug
coverPhoto {
id
url
}
}
}
`;
const SLUGLIST = `
{
posts {
slug
}
}
`;
const OnePost = ({ post }) => {
return (
<div>
<h1>One Post Page</h1>
<img
src={post.coverPhoto ? post.coverPhoto.url : null}
alt=""
height={200}
width={600}
></img>
<h2>{post.title}</h2>
</div>
);
};
export default OnePost;
import React from "react";
import { useQuery } from "react-query";
import axios from "axios";
import BlogCard from "../../components/BlogCard";
const endpoint =
"";
const QUERY = `
{
posts {
id
title
slug
coverPhoto {
createdBy {
id
}
url
}
}
}
`;
const AllPosts = () => {
const { data, isLoading, error } = useQuery("blog_posts", async () => {
const response = await axios({
url: endpoint,
method: "POST",
data: {
query: QUERY
}
});
return response.data.data;
});
if (isLoading) return "Loading...";
if (error) return <pre>{error.message}</pre>;
return (
<div>
<h1>Top Web Development Resources 2023</h1>
<ul>
{data.posts.map((post) => (
<BlogCard
title={post.title}
key={post.id}
coverPhoto={post.coverPhoto}
/>
))}
</ul>
</div>
);
};
export default AllPosts;
import React from "react";
import { QueryClient, QueryClientProvider } from "react-query";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import AllPosts from "./Pages/AllPosts/AllPosts";
import OnePost from "./Pages/OnePost/OnePost";
const queryClient = new QueryClient();
const App = () => (
<>
<Router>
<Switch>
<QueryClientProvider client={queryClient}>
<Route path="/" component={AllPosts} />
<Route path="/onepost" component={OnePost} />
<AllPosts />
</QueryClientProvider>
</Switch>
</Router>
</>
);
export default App;
The 2 images are examples of a list of posts and a single post, using the same data.


OnePostcomponent, and how are you trying to fetch it?api-ap-southeast-2.hygraph.comAPIs you are trying to use? It seems your question is basically how to make a specific query. Is the data for theOnePostcomponent different than the data from theAllPostscomponent?