MCPcopy Create free account
hub / github.com/TanStack/router / fetchPost

Function fetchPost

e2e/react-router/basic-react-query/src/posts.ts:21–33  ·  view source on GitHub ↗
(postId: string)

Source from the content-addressed store, hash-verified

19}
20
21const fetchPost = async (postId: string) => {
22 console.info(`Fetching post with id ${postId}...`)
23 const post = await axios
24 .get<PostType>(`${queryURL}/posts/${postId}`)
25 .then((r) => r.data)
26
27 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
28 if (!post) {
29 throw new NotFoundError(`Post with id "${postId}" not found!`)
30 }
31
32 return post
33}
34
35export const postQueryOptions = (postId: string) =>
36 queryOptions({

Callers 1

postQueryOptionsFunction · 0.70

Calls 2

infoMethod · 0.65
thenMethod · 0.65

Tested by

no test coverage detected