Skip to content

Commit

Permalink
docs(data-point/README.md): fix merge conflict (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
acatl committed Jan 25, 2018
1 parent a8e98b8 commit 3f24938
Showing 1 changed file with 0 additions and 81 deletions.
81 changes: 0 additions & 81 deletions packages/data-point/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1814,88 +1814,7 @@ For more information on acc.locals: [TransformOptions](#transform-options) and [

Example at: [examples/entity-request-string-template.js](examples/entity-request-options-locals.js)

<<<<<<< HEAD
##### <a name="transform-object">TransformObject</a>

A TransformObject is a Object where any property (at any level), that its key starts with the character `$` is treated as a [Reducer](#reducers). Properties that do not start with a `$` character will be left untouched.

When a TransformObject is to be resolved, all reducers are resolved in parallel. The `$` character will also be removed from the resolved property.

<details>
<summary>TransformObject Example</summary>

```js
dataPoint.addEntities({
'request:searchPeople': {
url: 'https://swapi.co/api/people',
options: {
// this request will be sent as:
// https://swapi.co/api/people/?search=r2
qs: {
// because the key starts
// with $ it will be treated
// as a reducer
$search: '$personName'
}
}
}
})

// second parameter to resolve is
// the input value
dataPoint
.resolve('request:searchPeople', {
personName: 'r2'
})
.then(output => {
// output.results[0].name -> 'R2-D2'
})
```
</details>


Example at: [examples/entity-request-transform-object.js](examples/entity-request-transform-object.js)

##### <a name="request-before-request">Request.beforeRequest</a>

There are times where you may want to process the `request.options` object before passing it to send the request.

This example simply provides the header object through a reducer. One possible use case for request.beforeRequest would be to set up [OAuth Signing](https://www.npmjs.com/package/request#oauth-signing).

<details>
<summary>Request.beforeRequest Example</summary>

```js
dataPoint.addEntities({
'request:getOrgInfo': {
url: 'https://api.github.com/orgs/{value}',
beforeRequest: (options) => {
// reference to request.options
return Object.assign({}, options, {
headers: {
'User-Agent': 'DataPoint'
}
})
}
}
})

dataPoint
.resolve('request:getOrgInfo', 'nodejs')
.then((output) => {
console.log(output)
// entire result from https://api.github.com/orgs/nodejs
})
```
</details>


Example at: [examples/entity-request-before-request.js](examples/entity-request-before-request.js)

For more examples of request entities, see the [Examples](examples), the unit tests: [Request Definitions](test/definitions/sources.js), and [Integration Examples](test/definitions/integrations.js)
=======
For more examples of request entities, see the [Examples](examples), the [Integration Examples](test/definitions/integrations.js), and the unit tests: [Request Definitions](test/definitions/sources.js).
>>>>>>> upstream/master

### <a name="request-inspect">Inspecting Request</a>

Expand Down

0 comments on commit 3f24938

Please sign in to comment.