const getPokemon = (id: number) =>
Effect.gen(function* () {
const res = yield* Effect.tryPromise({
try: () => fetch(`https://pokeapi.co/api/v2/pokemon/${id}`).then((res) => res.json()),
catch: () => new Error('error fetching pokemon'),
});
return yield* parsePokemon(res);
});
const getPokemon = (id: number) =>
Effect.gen(function* () {
const res = yield* Effect.tryPromise({
try: () => fetch(`https://pokeapi.co/api/v2/pokemon/${id}`).then((res) => res.json()),
catch: () => new Error('error fetching pokemon'),
});
return yield* parsePokemon(res);
});