Skip to content

Commit e296cd6

Browse files
authored
Merge pull request google#728 from google/dvanderb-update-batch-docs
Update batch documentation
2 parents 2370756 + 52fa020 commit e296cd6

File tree

2 files changed

+11
-149
lines changed

2 files changed

+11
-149
lines changed

docs/batch.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ The JavaScript client library supports batching HTTP requests to make multiple A
77
The JavaScript client library defines an object called `Batch`. You can start by instantiating this object:
88

99
```js
10-
var batch = gapi.client.newBatch();
10+
const batch = gapi.client.newBatch();
1111
```
1212

1313
## Adding requests to the batch
1414

15-
Use the `Batch` object's [`add`](reference.md#----gapiclientbatchaddrequestopt_params--) method to add individual HTTP requests. The `add` method supports one optional parameter:
15+
Use the `Batch` object's [`add`](reference.md#----gapiclientbatchaddrequestopt_params--) method to add individual HTTP requests. Only requests created via [discovery](discovery.md) should be added to a batch. The `add` method supports one optional parameter:
1616

1717
<table>
1818
<colgroup>
@@ -49,19 +49,18 @@ Use the `Batch` object's [`add`](reference.md#----gapiclientbatchaddrequestopt_p
4949
Example:
5050

5151
```js
52-
var searchRequest = function(name) {
53-
return gapi.client.request({
54-
'path': 'plus/v1/people',
55-
'params': {'query': name}
56-
});
57-
};
58-
var searchAlvin = searchRequest('Alvin');
59-
var searchSimon = searchRequest('Simon');
52+
const getMe = gapi.client.people.people.get({
53+
'resourceName': 'people/me'
54+
});
55+
56+
const getYou = gapi.client.people.people.get({
57+
'resourceName': 'people/you'
58+
});
6059

6160
// Adding just the request
62-
batch.add(searchAlvin);
61+
batch.add(getMe);
6362
// Adding the request with an ID
64-
batch.add(searchSimon, {'id': 'searchSimon'});
63+
batch.add(getYou, {'id': 'getYou'});
6564
```
6665

6766
## Executing a batch

samples/httpBatch.html

Lines changed: 0 additions & 137 deletions
This file was deleted.

0 commit comments

Comments
 (0)