getAllOrders: Effect.gen(function* (_) {
const response = yield* Effect.tryPromise({
try: () =>
fetch(API_ENDPOINT, {
headers: headers,
}),
catch: () => new FetchError({message: "Failed to fetch orders"}),
});
const jsonResp = yield* Effect.promise(() => response.json());
const orders = Schema.decodeUnknown(Schema.Array(Order))(jsonResp, {
errors: "all",
});
return yield* orders;
}).pipe(
Effect.catchTag("ParseError", (e) =>
Effect.log(`Failed to parse orders: ${e.message}`)
)
);
getAllOrders: Effect.gen(function* (_) {
const response = yield* Effect.tryPromise({
try: () =>
fetch(API_ENDPOINT, {
headers: headers,
}),
catch: () => new FetchError({message: "Failed to fetch orders"}),
});
const jsonResp = yield* Effect.promise(() => response.json());
const orders = Schema.decodeUnknown(Schema.Array(Order))(jsonResp, {
errors: "all",
});
return yield* orders;
}).pipe(
Effect.catchTag("ParseError", (e) =>
Effect.log(`Failed to parse orders: ${e.message}`)
)
);