Created
July 16, 2015 16:56
-
-
Save dhoss/4c11ae03de2c5bb48f87 to your computer and use it in GitHub Desktop.
trying to catch 404s
This file contains 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
devin@debian:~/projects/blaster$ activator test | |
[info] Loading project definition from /home/devin/projects/blaster/project | |
[info] Set current project to blaster (in build file:/home/devin/projects/blaster/) | |
[info] Compiling 1 Scala source to /home/devin/projects/blaster/target/scala-2.11/classes... | |
[error] /home/devin/projects/blaster/app/clients/Stash.scala:119: type mismatch; | |
[error] found : Unit | |
[error] required: scala.concurrent.Future[play.api.libs.json.JsValue] | |
[error] } | |
[error] ^ | |
[error] one error found | |
[error] (compile:compileIncremental) Compilation failed | |
[error] Total time: 5 s, completed Jul 15, 2015 6:58:58 PM |
This file contains 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
def callApi(url:String): Future[JsValue] = { | |
implicit val context = play.api.libs.concurrent.Execution.Implicits.defaultContext | |
val urlWithParams = url + "?" + pageSizeParam | |
val request: WSRequest = ws.url(urlWithParams) | |
val response = request.withHeaders( | |
"Accept" -> "application/json", | |
"Authorization" -> "Basic .....") | |
.get().map { response => | |
if (response.status == 200) { | |
response.json | |
} else { | |
Json.obj("error" -> response.status ) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment