Open History to see the last commit
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(
11 `https://jsonplaceholder.typicode.com/posts/${id}`,
12 )
13 const data = (await response.json()) as Post
14 return data
15}