File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
clients/algoliasearch-client-dart/packages/chopper_requester/example Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ import 'package:algolia_chopper_requester/algolia_chopper_requester.dart' ;
2
+ import 'package:algolia_client_core/algolia_client_core.dart' ;
3
+
4
+ void main () async {
5
+ const String appId = 'latency' ;
6
+ const String apiKey = '6be0576ff61c053d5f9a3225e2a90f76' ;
7
+
8
+ // Creating an instance of the RetryStrategy with necessary parameters.
9
+ // This will retry the failed requests with a backoff strategy.
10
+ final requester = RetryStrategy .create (
11
+ segment: AgentSegment (value: 'CustomClient' ),
12
+ appId: appId,
13
+ apiKey: apiKey,
14
+ defaultHosts: () => [
15
+ Host (url: 'latency-dsn.algolia.net' ),
16
+ Host (url: 'latency-1.algolianet.com' ),
17
+ ],
18
+ options: ClientOptions (
19
+ requester: ChopperRequester (
20
+ appId: appId,
21
+ apiKey: apiKey,
22
+ ),
23
+ ),
24
+ );
25
+
26
+ // Executing a GET request on the '/1/indexes/instant_search' endpoint.
27
+ final response = await requester.execute (
28
+ request: ApiRequest (
29
+ method: RequestMethod .get ,
30
+ path: '/1/indexes/instant_search' ,
31
+ queryParams: {'query' : 'a' , 'hitsPerPage' : '5' },
32
+ ),
33
+ );
34
+
35
+ // Printing json response.
36
+ print (response);
37
+
38
+ // Dispose of the requester to clean up its resources.
39
+ requester.dispose ();
40
+ }
You can’t perform that action at this time.
0 commit comments