Created
May 26, 2017 09:10
-
-
Save miguelsaddress/9e1a7fe0c6cad5e960bb249ec03ca829 to your computer and use it in GitHub Desktop.
Fetching Public User info from Github with Github4s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name := "GitHub4S Test" | |
version := "1.0" | |
scalaVersion := "2.12.2" | |
libraryDependencies += "com.47deg" %% "github4s" % "0.15.0" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.duration._ | |
import scala.concurrent.Await | |
import github4s.Github | |
import github4s.Github._ | |
import github4s.GithubResponses.GHResult | |
import github4s.jvm.Implicits._ | |
import scalaj.http.HttpResponse | |
object Main extends App { | |
val accessToken = Some("yourTokenHere") // not needed for public calls | |
val request = Github(None).users.get("miguelsaddress").execFuture[HttpResponse[String]]() | |
request.foreach { response => | |
response match { | |
case Right(GHResult(result, status, headers)) => println(result) | |
case Left(e) => println(e.getMessage) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment