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