Skip to content

Commit 8967819

Browse files
author
guylabs
committed
#1(doc): fix code example and add documentation about the response
1 parent 0a4457e commit 8967819

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,17 @@ SpringDataRestAdapter.process(response).then(function(processedResponse) {
154154
});
155155
```
156156

157-
Please read on on how to use the `_resources` method and the `_embeddedItems` property to ease the handling of resources and embedded items.
157+
The response can be a `String` or a promise from an `$http.get()` call (or any other promise which resolves the response) like in the following example:
158+
159+
```javascript
160+
var httpPromise = $http.get('/rest/categories');
161+
162+
SpringDataRestAdapter.process(httpPromise).then(function (processedResponse) {
163+
$scope.categories = processedResponse._embeddedItems;
164+
});
165+
```
166+
167+
For simplicity the rest of the examples assume that you already have the response present. Please read on on how to use the `_resources` method and the `_embeddedItems` property to ease the handling of resources and embedded items.
158168

159169
### Usage of `_resources` method
160170

@@ -465,7 +475,7 @@ SpringDataRestAdapter.process(promise).then(function(processedResponse) {
465475
You can also right away use the promise support with the `Angular` `$http.get()` method like in the following example:
466476
467477
```javascript
468-
SpringDataRestAdapter.processWithPromise($http.get('categories')).then(function(processedResponse) {
478+
SpringDataRestAdapter.process($http.get('categories')).then(function(processedResponse) {
469479
$scope.categories = processedResponse._embeddedItems;
470480
};
471481
```

0 commit comments

Comments
 (0)