0

我是 fp-ts 的新生,试图了解如何将一些东西组合在一起。

因此,我有例如 TaskEither,它正在执行 fetch 并且基于 fetch 的结果我想运行另一个 fetch 或跳转到下一步,目前,我已经这样做了。也许有人知道如何做到这一点的更好方法?


pipe(
  tryCatch(
    () => fetch('https://example.com'),
    reason => String(reason)
  ),
  chain(
    d => d ?
    tryCatch(
      () => fetch('https://example.com'),
      reason => String(reason)
    ) : right({})
  ),
  chain(
    finalResult => {
      //console.log(finalResult)
      return right(finalResult)
    }
  )
)

谢谢阅读:)

4

0 回答 0