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

Function fetchPost

examples/solid/basic-solid-query/src/posts.ts:20–33  ·  view source on GitHub ↗
(postId: string)

Source from the content-addressed store, hash-verified

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

Callers 1

postQueryOptionsFunction · 0.70

Calls 2

infoMethod · 0.65
thenMethod · 0.65

Tested by

no test coverage detected