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

Function fetchPost

e2e/solid-router/basic-file-based-code-splitting/src/posts.tsx:12–25  ·  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 const post = await axios
15 .get<PostType>(`${queryURL}/posts/${postId}`)
16 .then((r) => r.data)
17 .catch((err) => {
18 if (err.status === 404) {
19 throw notFound()
20 }
21 throw err
22 })
23
24 return post
25}
26
27export const fetchPosts = async () => {
28 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