title: Scala Nested Futures
body: <p>I have a couple of futures. campaignFuture returns a List[BigInt] and I want to be able to call the second future profileFuture for each of the values in the list returned from the first one. The second future can only be called when the first one is complete. How do I achieve this in Scala?</p>
  
  <pre><code>campaignFuture(1923).flatMap?? (May be?)
  
  def campaignFuture(advertiserId: Int): Future[List[BigInt]] = Future {
    val campaignHttpResponse = getCampaigns(advertiserId.intValue())
    parseProfileIds(campaignHttpResponse.entity.asString)
  }
  
  def profileFuture(profileId: Int): Future[List[String]] = Future {
    val profileHttpResponse = getProfiles(profileId.intValue())
    parseSegmentNames(profileHttpResponse.entity.asString)
  }    
  </code></pre>