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

Function fetchPost

examples/react/basic/src/posts.ts:19–32  ·  view source on GitHub ↗
(postId: string)

Source from the content-addressed store, hash-verified

17}
18
19export const fetchPost = async (postId: string) => {
20 console.info(`Fetching post with id ${postId}...`)
21 await new Promise((r) => setTimeout(r, 500))
22 const post = await axios
23 .get<PostType>(`https://jsonplaceholder.typicode.com/posts/${postId}`)
24 .then((r) => r.data)
25
26 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
27 if (!post) {
28 throw new NotFoundError(`Post with id "${postId}" not found!`)
29 }
30
31 return post
32}

Callers 9

posts.$postId.tsxFile · 0.90
posts.$postId.tsxFile · 0.90
posts.$postId.tsxFile · 0.90
posts.$postId.tsxFile · 0.90
main.tsxFile · 0.90
postQueryOptionsFunction · 0.50

Calls 2

infoMethod · 0.65
thenMethod · 0.65

Tested by

no test coverage detected