MCPcopy Create free account
hub / github.com/TanStack/query / getPosts

Function getPosts

examples/svelte/basic/src/lib/data.ts:3–7  ·  view source on GitHub ↗
(limit: number)

Source from the content-addressed store, hash-verified

1import type { Post } from './types'
2
3export const getPosts = async (limit: number) => {
4 const response = await fetch('https://jsonplaceholder.typicode.com/posts')
5 const data = (await response.json()) as Array<Post>
6 return data.filter((x) => x.id <= limit)
7}
8
9export const getPostById = async (id: number): Promise<Post> => {
10 const response = await fetch(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected