Skip to content

Commit 355e500

Browse files
committed
update dart guide
1 parent ec82249 commit 355e500

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

templates/dart/guides/search/saveObjectsMovies.mustache

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,10 @@ void main() async {
1111
Uri.parse('https://dashboard.algolia.com/sample_datasets/movie.json'));
1212

1313
if (datasetRequest.statusCode == 200) {
14-
final moviesData = jsonDecode(datasetRequest.body);
15-
16-
final batchRequests = <BatchRequest>[];
17-
18-
for (final movie in moviesData) {
19-
batchRequests.add(
20-
BatchRequest(action: Action.fromJson('addObject'), body: movie),
21-
);
22-
}
14+
final movies = jsonDecode(datasetRequest.body);
2315
16+
// push data to algolia
2417
{{#dynamicSnippet}}saveObjectsMovies{{/dynamicSnippet}}
25-
26-
try {
27-
// push data to algolia
28-
await client.batch(
29-
indexName: 'movies_index',
30-
batchWriteParams: BatchWriteParams(requests: batchRequests),
31-
);
32-
print("Successfully indexed records!");
33-
} catch (e) {
34-
print("Error: ${e.toString()}");
35-
}
3618
} else {
3719
throw Exception('Failed to load data');
3820
}

templates/dart/tests/method.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ try {
1212
expect(res, {{#match}}{{> tests/param_value}}{{/match}});
1313
{{/match.isPrimitive}}
1414
{{/testResponse}}
15+
print('successfully indexed records!');
1516
} on InterceptionException catch (_) {
1617
// Ignore InterceptionException
1718
}

0 commit comments

Comments
 (0)