title: Kotlin how to make multiple requests in a queue
body: <p>I have multiple requests, each request return 10 items. Something like this:</p>
  
  <pre><code>        var startIndex = 0
          var batchSize = 10
          var totoalCount = 50 
          var requestTimes = totoalCount/batchSize 
          for (index in 1..reqeustTimes) {
             client.request(url, "POST", startIndex) {
                 completion(result.map {
                    //store in an array and append the returned items
                 })
              startIndex += batchSize
          }
  </code></pre>
  
  <p>But I want to control the order, like put the request in a queue, one finished the start the next one.</p>
  
  <p>How should I do that?</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>completion: ((Result&lt;JsonObject&gt;) -&gt; Unit)? 
  </code></pre>
  
  <p>is an lambda.</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>I can make the request one by one, but the problem right now is the request isn't in order.</p>
  
  <pre><code>launch {   
            (1..parameter.totalSize/parameter.batchSize).asFlow()
                      .map { _ -&gt; fetchItem(parameter)}.collect()
  }
  </code></pre>