From 50935dd45662eee7a66f5ea12f440c78b1266a4f Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Tue, 10 May 2016 18:33:42 +0200 Subject: [PATCH] Fetch topologies sequentially on search --- client/app/scripts/utils/web-api-utils.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/client/app/scripts/utils/web-api-utils.js b/client/app/scripts/utils/web-api-utils.js index 570ac25a5..f54a70357 100644 --- a/client/app/scripts/utils/web-api-utils.js +++ b/client/app/scripts/utils/web-api-utils.js @@ -102,12 +102,15 @@ function createWebsocket(topologyUrl, optionsQuery, dispatch) { export function getAllNodes(getState, dispatch) { const state = getState(); const topologyOptions = state.get('topologyOptions'); - state.get('topologyUrlsById').forEach((topologyUrl, topologyId) => { - const optionsQuery = buildOptionsQuery(topologyOptions.get(topologyId)); - fetch(`${topologyUrl}?${optionsQuery}`) - .then(response => response.json()) - .then(json => dispatch(receiveNodesForTopology(json.nodes, topologyId))); - }); + // fetch sequentially + state.get('topologyUrlsById') + .reduce((sequence, topologyUrl, topologyId) => sequence.then(() => { + const optionsQuery = buildOptionsQuery(topologyOptions.get(topologyId)); + return fetch(`${topologyUrl}?${optionsQuery}`); + }) + .then(response => response.json()) + .then(json => dispatch(receiveNodesForTopology(json.nodes, topologyId))), + Promise.resolve()); } export function getTopologies(options, dispatch) {