In the code below I have to return the result of a future that is invoked after another future. I'm getting the following error in the future2.map
line:
type mismatch; found : scala.concurrent.Future[play.api.mvc.Result] required: play.api.mvc.Result
How to make this work?
def method1 = Action.async { request =>
val future1 = f1
future1.map { result1 =>
val future2 = f2
future2.map { result2 =>
Ok(result1+result2+"")
}
}
}
def f1 = Future { 1 }
def f2 = Future { 2 }