Add ordering, limits

This commit is contained in:
Greg Shuflin 2021-09-13 00:17:25 -07:00
parent a4c48b3cce
commit 0b9cd7ff54

View File

@ -44,10 +44,21 @@ function buildRequest(searchTerm: string, conlang: Conlang, direction: SearchDir
[Conlang.Elesu]: 'elesu', [Conlang.Elesu]: 'elesu',
}; };
const offset = 0;
const limit = 20;
const conlangDb = conlang.toString(); const conlangDb = conlang.toString();
const field = direction === SearchDirection.ToConlang ? 'eng' : specForConlang[conlang]; const conlangSpec = specForConlang[conlang];
const query = `${conlangDb}?${field}=like.*${searchTerm}*`; const field = direction === SearchDirection.ToConlang ? 'eng' : conlangSpec;
const effectiveUri = `${backendUrl}/${query}`;
const params = new URLSearchParams([
[field, `like.*${searchTerm}*`],
['order', conlangSpec],
['limit', limit],
['offset', offset],
]);
const effectiveUri = `${backendUrl}/${conlangDb}?${params}`;
fetch(`${effectiveUri}`) fetch(`${effectiveUri}`)
.then((resp) => resp.json()) .then((resp) => resp.json())