I want to call a second web service with the result from the first one.
Below is some code that highlights my intent.
By the way it compiles fine in IntelliJ(Probable a bug in the IDE).
def get = {
for {
respA <- WS.url(url1).get
id <- respA.body.split(",").take(2)
respB <- WS.url(url2 + id).get // Here is a compile error
} yield {
getMyObjects(respB.xml)
}
}
- respA = is a comma separated list with ids used in the next call.
- respB = is an XML response that I parse in the yield method
The compile error Play Framework
gives me:
type mismatch;
found : scala.concurrent.Future[Seq[MyObject]]
required: scala.collection.GenTraversableOnce[?]
I find the compile error strange.
- How can a
Future
of[Seq[MyObject]]
exist at that line? - It shouldn't be any different from the line two lines up that compiles?