Add ordering, limits
This commit is contained in:
parent
a4c48b3cce
commit
0b9cd7ff54
17
src/App.tsx
17
src/App.tsx
@ -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())
|
||||||
|
Loading…
Reference in New Issue
Block a user