Effect CommunityEC
Effect Community3y ago
31 replies
Dimitris

Removing `Failure` / `Success` Wrapper in TypeScript

How can I flatten this and remove the Failure / Success wrapper?
    return Effect.runPromiseExit(runnable).then(
      Exit.mapBoth({
        onFailure: (responseError) => {
          return typedjson({ok: false as const, errors: ['']}, {status: 401});
        },
        onSuccess: matchHttpResponse<T>()({
          Ok: ({data}) => {
            return typedjson({ok: true as const, data});
          },
          Redirect: ({to, init}) => {
            return redirect(to, init);
          },
        }),
      })
    );
Was this page helpful?