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

Function fetchPost

e2e/solid-router/basic-file-based/src/posts.tsx:12–26  ·  view source on GitHub ↗
(postId: string)

Source from the content-addressed store, hash-verified

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

Callers 1

posts.$postId.tsxFile · 0.90

Calls 4

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

Tested by

no test coverage detected