Files
effect-view/packages/example-next/src/post.ts
T
Julien Valverdé 31d87ffcab
Lint / lint (push) Successful in 38s
Fix
2026-07-19 04:00:46 +02:00

16 lines
377 B
TypeScript

import { Effect } from "effect"
export interface Post {
readonly title: string
readonly body: string
}
export const fetchPost = (id: number) => Effect.tryPromise({
try: () =>
fetch(`https://jsonplaceholder.typicode.com/posts/${id}`)
.then(response => response.json() as Promise<Post>),
catch: () => new Error("Unable to fetch post"),
})