mardi 21 avril 2015

How combine data from several responses in Scala Play2?

I need do some requests to different URLs, get data from their responses and put this info in one list, but i have some misunderstanding in this theme. 1) for one request i do

def doRequest: Future[WSResponse] = {

Then I parse json in response to List of my objects:

def list: Future[List[FoobarEntry]] = { {
  response => {
    val json = response.json \ "foobar"
      json.validate[List[FoobarEntry]] match {
      case js:JsSuccess[List[FoobarEntry]]=>
      case e:JsError => Logger.error(JsError.toFlatJson(e).toString()); List()

I think that for several url i should write some look like

def doRequests: List[Future[WSResponse]] = {

But how parse this list of Future[WSResponse] like my def list: Future[List[FoobarEntry]]?

Aucun commentaire:

Enregistrer un commentaire