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

Function fetchPost

e2e/solid-router/basic-solid-query/src/posts.ts:26–39  ·  view source on GitHub ↗
(postId: string)

Source from the content-addressed store, hash-verified

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

Callers 1

postQueryOptionsFunction · 0.70

Calls 2

infoMethod · 0.65
thenMethod · 0.65

Tested by

no test coverage detected