title: Scala future return based on first future result
body: <p>I have a Scala future that calls an api and returns future, if the result isn't correct, then another api call will be submitted with first future's result and returned as future.</p>
  
  <p>This is what I have so far.</p>
  
  <pre><code>val fut1 = Future(queryFirst)
  val fut2 = fut1 map {
    case y if y.isInstanceOf[NoResult] =&gt; Future(queryAgainWithFut1Result)
    case x =&gt; x
  }
  </code></pre>
  
  <p>But if I access fut2 result, it gives something like this:</p>
  
  <pre><code>scala.concurrent.Await.result(fut2, 5 seconds)
  warning: there was one feature warning; re-run with -feature for details
  fut2: Any = scala.concurrent.impl.Promise$DefaultPromise@61ab71c2
  </code></pre>
  
  <p>Is there a way that I can choose to return fut2 if fut1 result is not accurate?</p>
  
  <p><strong>Edit:</strong>
  Second future has to use first future to continue api call. This is what I have so far.</p>
  
  <pre><code>val fut1 = Future("queryFirst")
  val fut2 = fut1 flatMap {
    case y if y.isInstanceOf[Int] =&gt; Future("queryAgainWithResult(y)")
    case x =&gt; Future(x)
  }
  </code></pre>