title: How to make multiple HTTP GET requests based on previous future responses in Scala?
body: <p>I have several functions that have to make a GET request to a REST API. To get the code working, I need to make these calls synchronously as I have to pass some parameters that belong to the previous response. </p>
  
  <p>Imagine I have this function:</p>
  
  <pre><code>def getLocations(region: String, key: String): List[(Int, Int, String)] = {
  
      // ************1.*************
      val getLocationsURL = url("https://api.transitfeeds.com/v1/getLocations?").GET &lt;&lt;? List("key" -&gt; key)
  
      val response: Future[String] = Http.configure(_ setFollowRedirects true)(getLocationsURL OK as.String)
  
      //Evaluamos respuesta de la página
      response onComplete {
        case Success(content) =&gt; {
          //Make json
          val json = (parse(content) \\ "results" \\ "locations").children
  
          for (loc &lt;- json) {
  
            //Extract all locations
            val locations = loc.extract[List[Locations]]
  
            /*
            val countries = (locations.filter(w =&gt; w.t.contains(inputCountry))).map((x=&gt; (x.id, x.pid, x.n)))
            println(countries) //id, pid, n. Now we already have the list of regions interested in
            */
  
            val regions = (locations.filter(w =&gt; w.n.contains(inputRegion))).map((x =&gt; (x.id, x.pid, x.n)))
            println(regions) //id, pid, n. Now we already have the region interested in (only 1)
            finalRegion = regions
  
          }
        }
  
        case Failure(t) =&gt; {
          println("An error has occured: " + t.getMessage)
  
        }
      }
      return finalRegion
  
    }
  </code></pre>
  
  <p>Now I need the result of <code>finalRegion</code> to be inserted in another function that will make another HTTP GET request (almost the same as what is shown above), but I receive an error because the first future is not completed yet.</p>