cache pays
This commit is contained in:
parent
a8ed9ef172
commit
ddd50993a5
1 changed files with 9 additions and 2 deletions
|
@ -33,8 +33,7 @@ function buildOptions() {
|
|||
|
||||
async function defaultQueryFn(scope, term) {
|
||||
if (scope == 'pays') {
|
||||
const pays = await fetch('/pays.json').then((response) => response.json());
|
||||
return matchSorter(pays, term, { keys: ['nom'] });
|
||||
return matchSorter(await getPays(), term, { keys: ['nom'] });
|
||||
}
|
||||
|
||||
const url = buildURL(scope, term);
|
||||
|
@ -43,3 +42,11 @@ async function defaultQueryFn(scope, term) {
|
|||
promise.cancel = () => controller && controller.abort();
|
||||
return promise;
|
||||
}
|
||||
|
||||
let paysCache;
|
||||
async function getPays() {
|
||||
if (!paysCache) {
|
||||
paysCache = await fetch('/pays.json').then((response) => response.json());
|
||||
}
|
||||
return paysCache;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue