Skip to content

Commit

Permalink
Update batch documentation
Browse files Browse the repository at this point in the history
Update batch.md with discovery generated API sample
Remove httpBatch.html sample since it is duplicative of batch.md and out
of date(plus API does not exist anymore)
  • Loading branch information
dvanderb committed Apr 6, 2021
1 parent 2370756 commit 72b7a3e
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions docs/batch.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ The JavaScript client library supports batching HTTP requests to make multiple A
The JavaScript client library defines an object called `Batch`. You can start by instantiating this object:

```js
var batch = gapi.client.newBatch();
const batch = gapi.client.newBatch();
```

## Adding requests to the batch

Use the `Batch` object's [`add`](reference.md#----gapiclientbatchaddrequestopt_params--) method to add individual HTTP requests. The `add` method supports one optional parameter:
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:

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

```js
var searchRequest = function(name) {
return gapi.client.request({
'path': 'plus/v1/people',
'params': {'query': name}
});
};
var searchAlvin = searchRequest('Alvin');
var searchSimon = searchRequest('Simon');
const getMe = gapi.client.people.people.get({
'resourceName': 'people/me'
});

const getYou = gapi.client.people.people.get({
'resourceName': 'people/you'
});

// Adding just the request
batch.add(searchAlvin);
batch.add(getMe);
// Adding the request with an ID
batch.add(searchSimon, {'id': 'searchSimon'});
batch.add(getYou, {'id': 'getYou'});
```

## Executing a batch
Expand Down

0 comments on commit 72b7a3e

Please sign in to comment.