File tree Expand file tree Collapse file tree 1 file changed +2
-12
lines changed
playground/javascript/node Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Original file line number Diff line number Diff line change @@ -7,27 +7,17 @@ dotenv.config({ path: '../../.env' });
7
7
const appId = process . env . ALGOLIA_APPLICATION_ID || '**** APP_ID *****' ;
8
8
const apiKey = process . env . ALGOLIA_SEARCH_KEY || '**** SEARCH_API_KEY *****' ;
9
9
10
- const indexName = process . env . SEARCH_INDEX || 'test_index' ;
10
+ const searchIndex = process . env . SEARCH_INDEX || 'test_index' ;
11
11
const searchQuery = process . env . SEARCH_QUERY || 'test_query' ;
12
12
13
13
// Init client with appId and apiKey
14
14
const client = searchClient ( appId , apiKey ) ;
15
15
16
16
client . addAlgoliaAgent ( 'Node playground' , '0.0.1' ) ;
17
17
18
- type TObject = {
19
- name : string ;
20
- } ;
21
-
22
18
async function testSearch ( ) {
23
19
try {
24
- const res = await client . search < TObject > ( {
25
- requests : [ { indexName, query : searchQuery } ] ,
26
- } ) ;
27
-
28
- await client . browse ( { indexName } ) ;
29
-
30
- await client . searchSingleIndex ( { indexName, searchParams : { } } ) ;
20
+ const res = await client . search < { name : string } > ( { requests : [ { indexName : searchIndex , query : searchQuery } ] } ) ;
31
21
32
22
console . log ( `[OK]` , res . results [ 0 ] . hits ! [ 0 ] . name ) ;
33
23
} catch ( e : any ) {
You can’t perform that action at this time.
0 commit comments