Akka-http and converting Future[HttpResponse] to Future[String]
<p>I am working with Akka HTTP, and I have a client that queries a URL. The code is something like this:</p>

<pre><code>def f1(): Future[HttpResponse] =  { ... }
</code></pre>

<p>I want to write a <code>f2</code> function that takes the <code>HttpRespons</code>e but turns it into a <code>Future[String]</code> where the <code>String</code> is the body of the message. So I am looking for:</p>

<pre><code>def f2(): Future[String] = f1().map(...)
</code></pre>

<p>I am unable to convert the get this to work correctly. </p>

<p><strong>Question #1</strong>: This is more of a basic Scala question, I think. How would I convert this future? The best I can get is:</p>

<pre><code>def f2:Future[String] = {
 f1().map (_.entity.toStrict(300.milli).map(_.data.utf8String))
}
</code></pre>

<p>which doesn't work since I end up with a <code>Future[Future[String]]</code></p>

<p><strong>Question #2</strong>: This is an akka-http question for my understanding. </p>

<p>does <code>f1().map(_.toStrict())</code>   imply   <code>f1().map(_.entity.toStrict())</code> ?</p>

<p>If so, how can I access the entity without having to call toStrict on it as well?</p>