Type mismatch in recursive function using Bitbucket API and Playframework

45 Views Asked by At

I created a generic function to get from Bitbucket-API (It gives you the data in pages if there is to much data and the next page URL is under "next" in the response).

def getAggregatedDataWithNext[T](url: String)(implicit reader: Reads[T]): Future[Seq[T]]= {
    val featureResponse = ws.url(url).withAuth(AuthUserName, AuthPassword, WSAuthScheme.BASIC).addQueryStringParameters("pagelen" -> "100").get()
    featureResponse.map(response => {
      val resJson = response.json
      val tSequence = (resJson \ "values").as[Seq[T]]

      (resJson \ "next").asOpt[String] match {
        case None => tSequence
        case Some(nextUrl) => getAggregatedDataWithNext(nextUrl).flatMap(tSequence ++ _)
      }
    })
  }

I get an error:

type mismatch;
 found   : Seq[T]
 required: scala.concurrent.Future[?]

And IntelliJ gives me this: enter image description here

0

There are 0 best solutions below