-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgetSuggestions.mjs
29 lines (24 loc) · 907 Bytes
/
getSuggestions.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import bcfetch, { AutocompleteItemType } from '../../dist/mjs/index.js';
const autocompleteTagParams = {
itemType: AutocompleteItemType.Tag,
query: 'ambient'
};
const autocompleteLocationParams = {
itemType: AutocompleteItemType.Location,
query: 'Fin',
limit: 20
};
function printResults(results, params) {
const limit = params.limit !== undefined ? `, Limit: ${params.limit}` : '';
const title = `Autocomplete ${params.itemType.toLowerCase()} suggestions: ${params.query}${limit}`;
console.log(title);
console.log('-'.repeat(title.length));
console.log(JSON.stringify(results, null, 2));
console.log('');
}
bcfetch.autocomplete.getSuggestions(autocompleteTagParams).then((results) => {
printResults(results, autocompleteTagParams);
});
bcfetch.autocomplete.getSuggestions(autocompleteLocationParams).then((results) => {
printResults(results, autocompleteLocationParams);
});