[Maps] Fix new map showing no layers (#29799)

* [Maps] Fix new map showing no layers

* return async to function signature
This commit is contained in:
Nathan Reese 2019-02-01 07:16:27 -07:00 committed by GitHub
parent 2656666106
commit 22ca995911
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,21 +11,29 @@ import _ from 'lodash';
const GIS_API_RELATIVE = `../${GIS_API_PATH}`;
let meta = null;
let loadingMetaPromise = null;
let isLoaded = false;
export async function getDataSources() {
if (!meta) {
meta = new Promise(async (resolve, reject) => {
try {
const meta = await fetch(`${GIS_API_RELATIVE}/meta`);
const metaJson = await meta.json();
isLoaded = true;
resolve(metaJson.data_sources);
} catch(e) {
reject(e);
}
});
if (meta) {
return meta;
}
return meta;
if (loadingMetaPromise) {
return loadingMetaPromise;
}
loadingMetaPromise = new Promise(async (resolve, reject) => {
try {
const response = await fetch(`${GIS_API_RELATIVE}/meta`);
const metaJson = await response.json();
isLoaded = true;
meta = metaJson.data_sources;
resolve(meta);
} catch(e) {
reject(e);
}
});
return loadingMetaPromise;
}
export function getDataSourcesSync() {