Wait until all chart data page requests are complete before rendering.

This commit is contained in:
Jeff Stieler 2019-08-13 15:27:15 -07:00
parent edbbc33701
commit 6cb15280bb
1 changed files with 4 additions and 1 deletions

View File

@ -274,6 +274,7 @@ export function getReportChartData( options ) {
let isError = false;
const pagedData = [];
const totalPages = Math.ceil( stats.totalResults / MAX_PER_PAGE );
let pagesFetched = 1;
for ( let i = 2; i <= totalPages; i++ ) {
const nextQuery = { ...requestQuery, page: i };
@ -288,7 +289,9 @@ export function getReportChartData( options ) {
}
pagedData.push( _data );
if ( i === totalPages ) {
pagesFetched++;
if ( pagesFetched === totalPages ) {
isFetching = false;
break;
}