From our chat I can see that you want to you want to map each WS.Response to a JsonNode, with will leave you with a List<Promise<JsonNode>>. Promise.sequence can be used to convert that List<Promise<JsonNode>> to a Promise<List<JsonNode>>, which you can then map to Promise<Result>.

public static Promise<Result> index() {
    final Promise<WS.Response> resultPromiseJobs = WS.url("").get();
    final Promise<Result> result = resultPromiseJobs.flatMap(response -> {
        JsonNode jobListings = response.asJson();

        List<Job> jobs = ...

        List<Promise<JsonNode>> jsonResultsPromise = -> {
           Promise<WS.Response> resultPromiseStock = WS.url("secondURL?someQuery=job").get()); // this also returns a promise
           // map this to the retrieved JsonNode

        // Convert the list of promises into a promise of lists
        Promise<List<JsonNode>> jsonResults = Promise.sequence(jsonResultsPromise);

        // Now map to Promise<Result>;

    return result;

The catch here though is that if one of the Promises fails to complete, the entire list will fail. In many cases you might want this to happen if you need all the results. It's easy enough to discard failed Promises from a list in Scala using this method, but I'm not sure how to do it in Java without fold.

Related Query

More Query from same tag