Skip to content
This repository has been archived by the owner on Nov 16, 2018. It is now read-only.

Commit

Permalink
Add documentation for fetchEmbedded
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Grill committed Aug 3, 2016
1 parent d44fdd2 commit e071b56
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,23 @@ waterwheel.populateResources()

`.getFieldData()` accepts no arguments. This returns the object from Waterwheel-Drupal that contains information about each field in the entity/bundle. For a list of fields, _to be used in `.setField()`_, something like `Object.keys(res.fields)` will work.

### Get Embedded Resources

```javascript
waterwheel.api.node.page.get(1, 'hal_json')
.then(res => waterwheel.fetchEmbedded(res))
.then(res => {
// res
})
.catch(err => {
// err
});
```
`.fetchEmbedded()` accepts 1 argument
- `entityJSON`: This should be a HAL+JSON structured object containing an `_embedded` key at the root.

When requesting embedded resources duplicates are removed to prevent extra HTTP requests. An array is returned with your original response and any embedded resources. If any of the subsequent requests fail, the promise is rejected.

### Entity Query

To take advantage of the Entity Query support, enable the [EntityQueryAPI](https://www.drupal.org/project/entityqueryapi) module. You do not need to run `.populateResources()` prior to using this functionality.
Expand Down

0 comments on commit e071b56

Please sign in to comment.