Skip to content

Instantly share code, notes, and snippets.

@bijancn
Last active May 31, 2018 11:17
Show Gist options
  • Save bijancn/29e4d76c3987f5713a430ebf6f7948fc to your computer and use it in GitHub Desktop.
Save bijancn/29e4d76c3987f5713a430ebf6f7948fc to your computer and use it in GitHub Desktop.
def loadNumberOfItems(url: String): IO[Either[Exception, Int]] =
Url(url)
.toRight(InvalidUrl)
.map(request(_))
.traverse(_.map(_.getFieldOption("number").flatMap(_.as[Int]).toRight(InvalidJson)))
.map(_.flatten)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment