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',
};
const offset = 0;
const limit = 20;
const conlangDb = conlang.toString();
const field = direction === SearchDirection.ToConlang ? 'eng' : specForConlang[conlang];
const query = `${conlangDb}?${field}=like.*${searchTerm}*`;
const effectiveUri = `${backendUrl}/${query}`;
const conlangSpec = specForConlang[conlang];
const field = direction === SearchDirection.ToConlang ? 'eng' : conlangSpec;
const params = new URLSearchParams([
[field, `like.*${searchTerm}*`],
['order', conlangSpec],
['limit', limit],
['offset', offset],
]);
const effectiveUri = `${backendUrl}/${conlangDb}?${params}`;
fetch(`${effectiveUri}`)
.then((resp) => resp.json())