Need list outside map in play ws api call
<p>In a play-scala application, Im making a WS call:</p>

<pre><code>def getaddresses : ListBuffer[String] = {
   var lb = new ListBuffer[String]()
   var url = "xyz@xyx.com/someapi"

   WS.url(url).get.map {
      response =&gt;
        var emailsSeq = (response.json \\ "email")
        emailsSeq.foreach(lb+=_.toString())
        lb.foreach(println)     //This is filled with values
  }
  lb.foreach(println)           //This is empty
  lb
}
</code></pre>

<p>Inside map a sequence is returned whose entries I put in a ListBuffer lb to be returned by this method. 
The problem is that the the ListBuffer shows values inside map{} but does not show outside it. As a result empty ListBuffer is passed from the method.</p>

<p>I thought there might be a delay in ws response so tried the following which had no advantage:</p>

<pre><code>WS.url(url).withRequestTimeout(10.seconds).get.map {
</code></pre>

<p>Please help me in getting filled list buffer to be returned</p>