From 1b7ec40fec0ad00c1d4715d588135aa361ffc949 Mon Sep 17 00:00:00 2001 From: Sanjaiyan Parthipan Date: Wed, 1 Nov 2023 11:37:47 +0530 Subject: [PATCH] perf: Concurrent async request --- .../src/user_interface/src/client.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/visualization/client/Turi Create Visualization/src/user_interface/src/client.js b/src/visualization/client/Turi Create Visualization/src/user_interface/src/client.js index 7f5e55ad5a..d9bb0220df 100644 --- a/src/visualization/client/Turi Create Visualization/src/user_interface/src/client.js +++ b/src/visualization/client/Turi Create Visualization/src/user_interface/src/client.js @@ -34,13 +34,15 @@ export async function fetch(url, body) { } async function initVisualization(id, type) { - let spec = await fetch(`/spec/${type}/${id}`); var body = undefined; if (type === 'table') { // for table, fetch the first 100 rows by default body = {'type': 'rows', start: 0, end: 100}; } - var data = await fetch(`/data/${type}/${id}`, body); + let [spec, data] = await Promise.all([ + fetch(`/spec/${type}/${id}`), + fetch(`/data/${type}/${id}`, body), + ]); window.setSpec(spec); window.handleInput(data);