Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save abenevaut/4b706f7947cdbb666e2de11fd2d69381 to your computer and use it in GitHub Desktop.
Save abenevaut/4b706f7947cdbb666e2de11fd2d69381 to your computer and use it in GitHub Desktop.
import ReactDOM from 'react-dom/client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import App from './App';
import Projects from './Components/Projects';
const client = new QueryClient();
ReactDOM.createRoot(document.getElementById('root')).render(
<QueryClientProvider client={client}>
<App>
<Projects />
</App>
</QueryClientProvider>,
)
import { useQuery } from '@tanstack/react-query';
import axios from "axios";
function Projects() {
const { isPending, error, data } = useQuery({
queryFn: () => axios({
url: 'https://api.github.com/graphql',
method: "POST",
data: {
query: `{
user(login: "abenevaut") {
pinnedItems(first: 6, types: REPOSITORY) {
nodes {
... on Repository {
id,
name
}
}
}
}
}`
},
headers: {
Authorization: 'Bearer <GITHUB_TOKEN>'
}
}).then(response => response.data.data)
});
if (isPending) {
return "Loading...";
}
if (error) {
return <pre>{error.message}</pre>;
}
return (
<div>
<ul>
{ data.user.pinnedItems.nodes.map((project) => (
<li key={ project.id }>
<a href={`https://github.com/abenevaut/${project.name}`}>
{ project.name }
</a>
</li>
)) }
</ul>
</div>
)
}
@abenevaut
Copy link
Author

abenevaut commented Aug 7, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment