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

Function fetchPost

examples/react/basic-virtual-inside-file-based/src/posts.tsx:10–24  ·  view source on GitHub ↗
(postId: string)

Source from the content-addressed store, hash-verified

8}
9
10export const fetchPost = async (postId: string) => {
11 console.info(`Fetching post with id ${postId}...`)
12 await new Promise((r) => setTimeout(r, 500))
13 const post = await axios
14 .get<PostType>(`https://jsonplaceholder.typicode.com/posts/${postId}`)
15 .then((r) => r.data)
16 .catch((err) => {
17 if (err.status === 404) {
18 throw notFound()
19 }
20 throw err
21 })
22
23 return post
24}
25
26export const fetchPosts = async () => {
27 console.info('Fetching posts...')

Callers 1

details.tsxFile · 0.90

Calls 4

notFoundFunction · 0.85
infoMethod · 0.65
catchMethod · 0.65
thenMethod · 0.65

Tested by

no test coverage detected