Open History to see the last commit
1import { useQuery } from "react-query";
2import axios from "axios";
3β
4const getPostById = async (_, postId) => {
5 const { data } = await axios.get(
6 `https://jsonplaceholder.typicode.com/posts/${postId}`
7 );
8 return data;
9};
10β
11export default function usePost(postId) {
12 return useQuery(["post", postId], getPostById);
13}