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

Function fetchPost

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

Source from the content-addressed store, hash-verified

11const queryURL = 'https://jsonplaceholder.typicode.com'
12
13export const fetchPost = async (postId: string) => {
14 console.info(`Fetching post with id ${postId}...`)
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 new PostNotFoundError(`Post with id "${postId}" not found!`)
21 }
22 throw err
23 })
24
25 return post
26}
27
28export const fetchPosts = async () => {
29 console.info('Fetching posts...')

Callers 1

postQueryOptionsFunction · 0.90

Calls 3

infoMethod · 0.65
catchMethod · 0.65
thenMethod · 0.65

Tested by

no test coverage detected