(postId: string)
| 11 | const queryURL = 'https://jsonplaceholder.typicode.com' |
| 12 | |
| 13 | export 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 | |
| 28 | export const fetchPosts = async () => { |
| 29 | console.info('Fetching posts...') |
no test coverage detected