Skip to content

Commit 3d3eb51

Browse files
committed
Add $http service in the configuration phase
1 parent 517e977 commit 3d3eb51

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,23 @@ The config method of the `SpringDataRestAdapterProvider` takes a configuration o
519519
"fetchAllKey": "_allLinks"
520520
}
521521
```
522+
If you want to use the `$http` service inside the fetch function in the configuration phase then you need to use the Angular injector to get the `$http` service:
523+
524+
```javascript
525+
myApp.config(function (SpringDataRestAdapterProvider) {
526+
527+
// set the new fetch function
528+
SpringDataRestAdapterProvider.config({
529+
fetchFunction: function (url, key, data, fetchLinkNames, recursive) {
530+
var $http = angular.injector(['ng']).get('$http');
531+
532+
$http.get('/rest/endpoint').then(function (responseData) {
533+
console.log(responseData);
534+
})
535+
}
536+
});
537+
});
538+
```
522539
523540
## The `SpringDataRestInterceptor`
524541

0 commit comments

Comments
 (0)