I want to return a boolean from the network request and perform action based on that boolean response. Right now I can't do that because the type Any doesnt get converted to boolean. Could someone help?
def tetetetestae() = Action.async { implicit request =>
request.session.get("email") match {
case Some(email) =>
for {
t <- test("","","","","")
} yield {
if(t){
Ok("")
} else {
Ok("")
}
}
}
}
}
def test(email: String, firstName: String, lastName: String, c_password: String, n_password: String) = {
WS.url("http://hire.monster.com:81/authenticateUser")
.post(Map("email" -> Seq(email), "password" -> Seq(c_password)))
.map(response =>
if(response.body.contains("true")){
for(result <- WS.url("http://localhost:9001/settings/updateUser")
.post(Map("email" -> Seq(email), "firstName" -> Seq(firstName), "lastName" -> Seq(lastName), "n_password" -> Seq(n_password))))
yield result.body.contains("true")
} else {
false
})
}
You can try this:
This will return the
Future[Boolean]
you need.