{"id":15632901,"url":"https://github.com/guylabs/angular-spring-data-rest","last_synced_at":"2025-04-09T21:16:07.030Z","repository":{"id":19591984,"uuid":"22842412","full_name":"guylabs/angular-spring-data-rest","owner":"guylabs","description":"An AngularJS module to ease the work with a Spring Data REST backend.","archived":false,"fork":false,"pushed_at":"2017-04-18T08:57:55.000Z","size":434,"stargazers_count":162,"open_issues_count":1,"forks_count":39,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-09T21:16:02.111Z","etag":null,"topics":["angular","hal","hateoas","spring","spring-data","spring-data-rest","spring-hateoas"],"latest_commit_sha":null,"homepage":"http://guylabs.ch/project/angular-spring-data-rest","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guylabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-11T14:42:48.000Z","updated_at":"2024-10-11T12:15:20.000Z","dependencies_parsed_at":"2022-09-11T07:01:19.306Z","dependency_job_id":null,"html_url":"https://github.com/guylabs/angular-spring-data-rest","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guylabs%2Fangular-spring-data-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guylabs%2Fangular-spring-data-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guylabs%2Fangular-spring-data-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guylabs%2Fangular-spring-data-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guylabs","download_url":"https://codeload.github.com/guylabs/angular-spring-data-rest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248111973,"owners_count":21049578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","hal","hateoas","spring","spring-data","spring-data-rest","spring-hateoas"],"created_at":"2024-10-03T10:45:43.053Z","updated_at":"2025-04-09T21:16:07.010Z","avatar_url":"https://github.com/guylabs.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/guylabs/angular-spring-data-rest.svg?branch=master)](https://travis-ci.org/guylabs/angular-spring-data-rest)\n[![Coverage Status](https://img.shields.io/coveralls/guylabs/angular-spring-data-rest.svg)](https://coveralls.io/r/guylabs/angular-spring-data-rest)\n[![Bower version](https://badge.fury.io/bo/angular-spring-data-rest.svg)](http://badge.fury.io/bo/angular-spring-data-rest)\n[![npm version](https://badge.fury.io/js/angular-spring-data-rest.svg)](http://badge.fury.io/js/angular-spring-data-rest)\n\n# angular-spring-data-rest\n\n\u003e An AngularJS module with an additional interceptor which eases the work with a [Spring Data REST](http://projects.spring.io/spring-data-rest) backend.\n\n## See how it works\n\nIf you want to see the module in action, then check out the sample application which runs with Spring Boot and is super easy to setup: [angular-spring-data-rest-sample](https://github.com/guylabs/angular-spring-data-rest-sample)\n\n# Table of contents\n\n- [Quick start](#quick-start)\n- [Overview](#overview)\n- [The `SpringDataRestAdapter`](#the-springdatarestadapter)\n    - [Usage of `SpringDataRestAdapter`](#usage-of-springdatarestadapter)\n    - [Usage of `_resources` method](#usage-of-_resources-method)\n        - [The `_resources` method parameters and return type](#the-_resources-method-parameters-and-return-type)\n        - [`_resources` usage example](#_resources-usage-example)\n        - [Exchange the underlying Angular `$resource` function](#exchange-the-underlying-angular-resource-function)\n    - [Usage of `_embeddedItems` property](#usage-of-_embeddeditems-property)\n        - [`_embeddedItems` usage example](#_embeddeditems-usage-example)\n    - [How to automatically fetch links](#how-to-automatically-fetch-links)\n        - [Fetch multiple or all links](#fetch-multiple-or-all-links)\n        - [Exchange the underlying fetch function](#exchange-the-underlying-fetch-function)\n        - [The fetch method parameters](#the-fetch-method-parameters)\n    - [How to use `SpringDataRestAdapter` with promises](#how-to-use-springdatarestadapter-with-promises)\n    - [Configuration of the `SpringDataRestAdapter`](#configuration-of-the-springdatarestadapter)\n- [The `SpringDataRestInterceptor`](#the-springdatarestinterceptor)\n- [Dependencies](#dependencies)\n- [Release notes](#release-notes)\n- [Acknowledgements](#acknowledgements)\n- [License](#license)\n\n\n## Quick start\n\nTo use the `SpringDataRestAdapter` *Angular* module with [bower](http://bower.io) execute the following command to install the package:\n\n```bash\nbower install angular-spring-data-rest\n```\nor with [npm](https://www.npmjs.com/):\n```bash\nnpm install angular-spring-data-rest\n```\n\n## Overview\n\n*Spring Data REST* integrates [Spring HATEOAS](http://projects.spring.io/spring-hateoas) by default. This simplifies the creation of REST presentations which are generated with the [HATEOAS](http://en.wikipedia.org/wiki/HATEOAS) principle.\n\nTherefore the *Spring Data REST* responses have resources and embedded resources like in the following JSON response example:\n\n```json\n{\n    \"_links\": {\n        \"self\": {\n            \"href\": \"http://localhost:8080/categories{?page,size,sort}\",\n            \"templated\": true\n        }\n    },\n    \"_embedded\": {\n        \"categories\": [\n            {\n                \"name\": \"Test category 1\",\n                \"_links\": {\n                    \"self\": {\n                        \"href\": \"http://localhost:8080/categories/1\"\n                    },\n                    \"parentCategory\": {\n                        \"href\": \"http://localhost:8080/categories/1/parentCategory\"\n                    }\n                }\n            },\n            {\n                \"name\": \"Test category 2\",\n                \"_links\": {\n                    \"self\": {\n                        \"href\": \"http://localhost:8080/categories/2\"\n                    },\n                    \"parentCategory\": {\n                        \"href\": \"http://localhost:8080/categories/2/parentCategory\"\n                    }\n                }\n            }\n        ]\n    },\n    \"page\": {\n        \"size\": 20,\n        \"totalElements\": 2,\n        \"totalPages\": 1,\n        \"number\": 0\n    }\n}\n```\nThe above response is the result of calling the endpoint to get all categories(`http://localhost:8080/categories`). It contains the `_links` property which holds an object with several named resources(e.g. `self`). These resources are used to navigate to a related entity(e.g. `parentCategory`) or to a specific endpoint defined by the backend.\n\nThe `_embedded` property holds an array of the requested items, and each of the items has again a `_links` property which defines the resources for the specific item. You can find more about how the responses of *Spring Data REST* look like [here](http://projects.spring.io/spring-data-rest).\n\nThis *Angular* module provides two ways of processing a response from the *Spring Data REST* backend and ease the usage with the resources and embedded items:\n\n1. Using an instance of the `SpringDataRestAdapter`.\n2. Add the `SpringDataRestInterceptor` to the Angular `$httpProvider.interceptors` such that all responses are processed.\n\n## The `SpringDataRestAdapter`\n\nThe `spring-data-rest` *Angular* module provides a provider for the `SpringDataRestAdapter` object. This object is the core of the module and it processes a given response and adds the following additional properties/methods to it:\n\n1. `_resources`: this method wraps the *Angular* `$resource` function by default (this is [exchangeable](#exchange-the-underlying-angular-resource-function)) and adds an easy way to retrieve the resources defined in the `_links` property. It is also used to retrieve all available resources of the given object. Read more about this method [here](#usage-of-_resources-method).\n2. `_embeddedItems`: this property replaces the `_embedded` property and sets the named array (`categories` in the upper example response) with the embedded items as its value. Read more about this property [here](#usage-of-_embeddedItems-property).\n\nSpring Data REST also generates an index response when you make a `GET` response to the configured base url of the dispatcher servlet. This response looks like the following example:\n\n```javascript\n{\n  \"_links\" : {\n    \"users\" : {\n      \"href\" : \"http://localhost:8080/users{?page,size,sort}\",\n      \"templated\" : true\n    },\n    \"categories\" : {\n      \"href\" : \"http://localhost:8080/categories{?page,size,sort}\",\n      \"templated\" : true\n    },\n    \"accounts\" : {\n      \"href\" : \"http://localhost:8080/accounts{?page,size,sort}\",\n      \"templated\" : true\n    },\n    ...\n  }\n}\n```\n\nThis response shows all configured Spring Data REST repositories and the links to these resources. The `SpringDataRestAdapter` is also able to handle this response and to provide an easy method to retrieve all the available resources with the `_resources` method. Please read more about this [here](#the-_resources-method-parameters-and-return-type).\n\nAnother feature is that the `SpringDataRestAdapter` is able to automatically fetch the links of a resource and adds the response of the link as a property to the main response. Please read more about this [here](#how-to-automatically-fetch-links).\n\n### Usage of `SpringDataRestAdapter`\n\nTo use the `SpringDataRestAdapter` object you need to include the `angular-spring-data-rest.js` file (or the minified version) and add the `spring-data-rest` module as a dependency in your module declaration:\n\n```javascript\nvar myApp = angular.module(\"myApplication\", [\"ngResource\", \"spring-data-rest\"]);\n```\n\nNow you are able use the `SpringDataRestAdapter` object and process a given response and you will get a promise back which resolves with the processes response:\n\n```javascript\nSpringDataRestAdapter.process(response).then(function(processedResponse) {\n  ...\n});\n```\n\nThe 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:\n\n```javascript\nvar httpPromise = $http.get('/rest/categories');\n\nSpringDataRestAdapter.process(httpPromise).then(function (processedResponse) {\n    $scope.categories = processedResponse._embeddedItems;\n});\n```\n\nFor 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.\n\n### Usage of `_resources` method\n\nThe `_resources` property is added on the same level of the JSON response object where a `_links` property exists. When for example the following JSON response object is given:\n\n```javascript\nvar response = {\n    \"_links\": {\n        \"self\": {\n            \"href\": \"http://localhost:8080/categories{?page,size,sort}\",\n            \"templated\": true\n        }\n    },\n    \"_embedded\": {\n        ...\n    }\n    ...\n}\n```\n\nThen the `SpringDataRestAdapter` will add the `_resources` method to the same level such that you can call it the following way (inside the `then` function of the promise):\n\n```javascript\nSpringDataRestAdapter.process(response).then(function(processedResponse) {\n  processedResponse._resources(linkName, paramDefaults, actions, options);\n});\n```\n\nThis `_resources` method is added recursively to all the properties of the JSON response object where a `_links` property exists.\n\n#### The `_resources` method parameters and return type\n\nThe `_resources` method takes the following four parameters:\n\n* `linkName`: the name of the link's `href` you want to call with the underlying *Angular* `$resource` function. You can also pass in a resource object with parameters in the following way:\n\n```javascript\nSpringDataRestAdapter.process(response).then(function(processedResponse) {\n  var resourceObject = {\n    \"name\": \"self\",\n    \"parameters\": {\n        \"size\": 20,\n        \"sort\": \"asc\"\n    }\n  }\n  processedResponse._resources(resourceObject, paramDefaults, actions, options);\n});\n```\n\nThis will call *Angular* `$resource` method by default (this is [exchangeable](#exchange-the-underlying-angular-resource-function)) with the `href` of the `self` resource and will add the parameters `size` and `sort` as query string to the URL. If the resource object parameters and the `paramDefaults` parameters are set, then these two objects are merged such that the resource object parameters appear first in the new object and the `paramDefaults` parameters last.\n\n* `paramDefaults`: the default values for url parameters. Read more  [here](https://docs.angularjs.org/api/ngResource/service/$resource).\n* `actions`: custom action that should extend the default set of the `$resource` actions. Read more [here](https://docs.angularjs.org/api/ngResource/service/$resource).\n* `options`: custom settings that should extend the default `$resourceProvider` behavior Read more [here](https://docs.angularjs.org/api/ngResource/service/$resource).\n\nYou are also able to add URL templates to the passed in `linkName` parameter. (This just works if you pass a string and not a resource object) The following example explains the usage:\n\n```javascript\nSpringDataRestAdapter.process(response).then(function(processedResponse) {\n  var resources = processedResponse._resources(\"self/:id\", {id: \"@id\"});\n  var item = resources.get({id: 1}).then(function(data) {\n    item = data;\n  };\n});\n```\n\nThe `_resources` method returns the *Angular* resource \"class\" object with methods for the default set of resource actions. Read more [here](https://docs.angularjs.org/api/ngResource/service/$resource).\n\nIf no parameter is given the `_resources` method will return all available resources objects of the given object. When for example the following JSON response object is given:\n\n```javascript\nvar response = {\n    \"_links\": {\n        \"self\": {\n            \"href\": \"http://localhost:8080/categories{?page,size,sort}\",\n            \"templated\": true\n        },\n        \"parentCategory\": {\n            \"href\": \"http://localhost:8080/categories/1/parentCategory\"\n        }\n    },\n    \"_embedded\": {\n        ...\n    }\n    ...\n}\n```\nThen the following call to the `_resources` method without any parameter will return an array of all available resource objects.\n\n```javascript\nSpringDataRestAdapter.process(response).then(function(processedResponse) {\n  var availableResources = processedResponse._resources();\n});\n```\n\nThe above call will result in the following return value:\n\n```json\n[\n    {\n        \"name\":\"self\",\n        \"parameters\": {\n            \"page\": \"\",\n            \"size\": \"\",\n            \"sort\": \"\"\n        }\n    },\n    {\n        \"name\":\"parentCategory\"\n    }\n]\n```\n\nThis functionality is useful if you want to first check all available resources before using the `_resources` method to retrieve the specific resource.\n\n#### `_resources` usage example\n\nThis example refers to the JSON response in the [Overview](#overview). If you want to get the parent category of a category you would call the `_resources` method the following way:\n\n```javascript\nSpringDataRestAdapter.process(response).then(function(processedResponse) {\n  var parentCategoryResource = processedResponse._embeddedItems[0]._resources(\"parentCategory\");\n\n  // create a GET request, with the help of the Angular resource class, to the parent category\n  // url and log the response to the console\n  var parentCategory = parentCategoryResource.get(function() {\n    console.log(\"Parent category name: \" + parentCategory.name);\n  });\n});\n```\n\n#### Exchange the underlying Angular `$resource` function\n\nIf you want to exchange the underlying call to the *Angular* `$resource` method then you are able to do this within the configuration of the `SpringDataRestAdapter`. By default it will use the *Angular* `$resource` function.\n\nThe following example shows how to set a custom function:\n\n```javascript\nmyApp.config(function (SpringDataRestAdapterProvider) {\n\n    // set the new resource function\n    SpringDataRestAdapterProvider.config({\n        'resourcesFunction': function (url, paramDefaults, actions, options) {\n            // do the call to the backend and return your desired object\n        }\n    });\n});\n```\n\nThe description of the parameters you will find [here](#the-_resources-method-parameters-and-return-type). You can also read more about the configuration of the `SpringDataRestAdapter` [here](#configuration-of-the-springdatarestadapter) (and how to use the `$http` service in the configuration phase)\n\n### Usage of `_embeddedItems` property\n\nThe `_embeddedItems` property is just a convention property created by the `SpringDataRestAdapter` to easily iterate over the `_emebedded` items in the response. Like with the `_resources` method, the `SpringDataRestAdapter` will recursively create an `_embeddedItems` property on the same level as a `_embedded` property exists for all the JSON response properties.\n\n#### `_embeddedItems` usage example\n\nThis example refers to the JSON response in the [Overview](#overview). If you want to iterate over all categories in the response you would do it in the following way:\n\n```javascript\nSpringDataRestAdapter.process(response).then(function(processedResponse) {\n\n  // log the name of all categories contained in the response to the console\n  angular.forEach(processedResponse._embeddedItems, function (category, key) {\n    console.log(\"Category name: \" + category.name);\n  });\n});\n```\n\n**Be aware** that the original `_embedded` property gets deleted after the `SpringDataRestAdapter` processed the response.\n\n### How to automatically fetch links\n\nThe `SpringDataRestAdapter` is able to fetch specified links automatically. This means that if you have the following response:\n\n```json\n{\n    \"_links\": {\n        \"self\": {\n            \"href\": \"http://localhost:8080/categories{?page,size,sort}\",\n            \"templated\": true\n        },\n        \"anotherLink\": {\n            \"href\": \"http://localhost:8080/anotherLink\"\n        }\n    },\n    ...\n}\n```\nand you want to fetch the data from the `anotherLink` link then you just need to pass the link name to the `SpringDataRestAdapter` process function:\n\n```javascript\nSpringDataRestAdapter.process(response, 'anotherLink').then(function(processedResponse) {\n  var fetchedObject = processedResponse.anotherLink;\n});\n```\nNow you are able to get the data from the processed resource by just accessing the property named `anotherLink`.\n\nThe `SpringDataRestAdapter` by default adds the response of the link to a property in the original response with the same name as the link.\n\nIf you want to process the returned response again with the `SpringDataRestAdapter` then you are able to set the `recursive` flag when creating it:\n\n```javascript\nSpringDataRestAdapter.process(response, 'anotherLink', true).then(function(processedResponse) {\n  ...\n});\n```\n\nNow the response of the `anotherLink` will be processed the same way as the main response was processed. But *be aware* when setting the recursive flag to true, because when your responses of the links contain the same link name again, then it will end up in a infinite loop.\n\nIt will not fetch the `self` link as this would make no sense because the data is already in the response. The `self` key is also configurable. Read more [here](#configuration-of-the-springdatarestadapter).\n\nAs a last configuration option you are able to set the fourth parameter called `fetchMultiple` of the `process` method which is used to define if a link is fetched multiple times if the same link is contained in multiple links and you want to resolve each one of them. The drawback\nis that it won't cache the responses in any way. So if you enable this then multiple network calls will be made. Here an example:\n\n```javascript\nSpringDataRestAdapter.process(response, 'anotherLink', true, true).then(function(processedResponse) {\n  ...\n});\n```\n\n:warning: If you set the `fetchMultiple` to `true` you could end up in an infinite loop if you have circular dependencies in your `_links`.\n\n#### Fetch multiple or all links\n\nIf you want to fetch multiple links then you are able to add an array of strings with the given link names:\n\n```javascript\nSpringDataRestAdapter.process(response, ['anotherLink', 'testLink']).then(function(processedResponse) {\n  ...\n});\n```\nand if you want to fetch all links, then you can use the predefined and also configurable `fetchAllLinkNamesKey`:\n\n```javascript\nSpringDataRestAdapter.process(response, '_allLinks').then(function(processedResponse) {\n  ...\n});\n```\n\nPlease read more [here](#configuration-of-the-springdatarestadapter) on how to configure the `fetchAllLinkNamesKey`.\n\n#### Exchange the underlying fetch function\n\nIf you want to exchange the underlying function to fetch the links then you are able to do this within the configuration of the `SpringDataRestAdapter`. By default it will use the *Angular* `$http` function.\n\nThe following example shows how to set a custom function:\n\n```javascript\nmyApp.config(function (SpringDataRestAdapterProvider) {\n\n    // set the new resource function\n    SpringDataRestAdapterProvider.config({\n        'fetchFunction': function (url, key, data, fetchLinkNames, recursive) {\n            // fetch the url and add the key to the data object\n        }\n    });\n});\n```\n\nThe description of the parameters you will find [here](#the-fetch-method-parameters). You can also read more about the configuration of the `SpringDataRestAdapter` [here](#configuration-of-the-springdatarestadapter) (and how to use the `$http` service in the configuration phase)\n\n#### The fetch method parameters\n\nThe parameters for the fetch method are the following:\n\n* `url`: The url of the link from which to fetch the data.\n* `key`: The name of the link which is used to name the property in the data object.\n* `data`: The data object in which the new property is created with the response of the called `url`.\n* `fetchLinkNames`: The fetch link names to allow to process the fetched response recursiveley\n* `recursive`: True if the fetched response should be processed recursively, false otherwise.\n\n### How to use `SpringDataRestAdapter` with promises\n\nThe `SpringDataRestAdapter` is also able to process promises instead of data objects. The data object which is passed to the specified promise when it is resolved needs to be in the following formats:\n\n```javascript\n{\n    data: {\n        \"_links\": {\n            \"self\": {\n                \"href\": \"http://localhost:8080/categories{?page,size,sort}\",\n                \"templated\": true\n            },\n            \"anotherLink\": {\n                \"href\": \"http://localhost:8080/anotherLink\"\n            }\n        },\n        // the rest of the JSON response\n        ...\n    }\n}\n```\nor\n```javascript\n{\n    \"_links\": {\n        \"self\": {\n            \"href\": \"http://localhost:8080/categories{?page,size,sort}\",\n            \"templated\": true\n        },\n        \"anotherLink\": {\n            \"href\": \"http://localhost:8080/anotherLink\"\n        }\n    },\n    // the rest of the JSON response\n    ...\n}\n```\n\nThe `data` property of the second format of the promise object is the JSON response of the back end. To process such a promise you need to call the `SpringDataRestAdapter` like in the following example:\n\n```javascript\nSpringDataRestAdapter.process(promise).then(function(processedResponse) {\n    // you can now use the processedResponse as any other processed response from the SpringDataRestAdapter\n};\n```\n\nYou can also right away use the promise support with the `Angular` `$http.get()` method like in the following example:\n\n```javascript\nSpringDataRestAdapter.process($http.get('categories')).then(function(processedResponse) {\n    $scope.categories = processedResponse._embeddedItems;\n};\n```\n\n### Configuration of the `SpringDataRestAdapter`\n\nThe `SpringDataRestAdapter` is designed to be configurable and you are able to configure the following properties:\n\n* `linksKey` (default: `_links`): the property name where the resources are stored.\n* `linksHrefKey` (default: `href`): the property name where the URL is stored in a link object.\n* `linksSelfLinkName` (default: `self`): the name of the self link in the links object.\n* `embeddedKey` (default: `_embedded`): the property name where the embedded items are stored.\n* `embeddedNewKey` (default: `_embeddedItems`): the property name where the array of embedded items are stored.\n* `embeddedNamedResources` (default: `false`): true if the embedded resources names (can be more than one) should be\nleft as is, false if they should be removed and be replaced by the value of the first embedded resource\n    * Example if set to true:\n    ```json\n    {\n        ...\n        \"_embeddedItems\": {\n            \"categories\": [...]\n        }\n        ...\n    }\n    ```\n    * Example if set to false:\n    ```json\n    {\n        ...\n        \"_embeddedItems\": [...]\n        ...\n    }\n    ```\n* `hrefKey` (default: `href`): the property name where the url is stored under each specific link.\n* `resourcesKey` (default: `_resources`): the property name where the resource method is stored.\n* `resourcesFunction` (default: `undefined`): the function to use to call the backend. Read more how to do this [here](#exchange-the-underlying-angular-resource-function)\n* `fetchFunction` (default: `undefined`): the function to use to fetch data from the backend. Read more how to do this [here](#exchange-the-underlying-fetch-function)\n* `fetchAllKey` (default: `_allLinks`): the key to pass to the `SpringDataRestAdapter` to fetch all available links\n\nYou are able to configure the `SpringDataRestAdapter` provider in a *Angular* configuration block in the following way:\n\n```javascript\nmyApp.config(function (SpringDataRestAdapterProvider) {\n\n    // set the links key to _myLinks\n    SpringDataRestAdapterProvider.config({\n        'linksKey': '_myLinks'\n    });\n});\n```\n\nThe config method of the `SpringDataRestAdapterProvider` takes a configuration object and you are able to override each value or completely replace the whole configuration object. The default configuration object looks like this:\n\n```json\n{\n    \"linksKey\": \"_links\",\n    \"linksHrefKey\": \"href\",\n    \"linksSelfLinkName\": \"self\",\n    \"embeddedKey\": \"_embedded\",\n    \"embeddedNewKey\": \"_embeddedItems\",\n    \"embeddedNamedResources\": false,\n    \"resourcesKey\": \"_resources\",\n    \"resourcesFunction\": undefined,\n    \"fetchFunction\": undefined,\n    \"fetchAllKey\": \"_allLinks\"\n}\n```\nIf 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:\n\n```javascript\nmyApp.config(function (SpringDataRestAdapterProvider) {\n\n    // set the new fetch function\n    SpringDataRestAdapterProvider.config({\n        fetchFunction: function (url, key, data, fetchLinkNames, recursive) {\n            var $http = angular.injector(['ng']).get('$http');\n\n            $http.get('/rest/endpoint').then(function (responseData) {\n                console.log(responseData);\n            })\n        }\n    });\n});\n```\n\n## The `SpringDataRestInterceptor`\n\nIf you want to use the `SpringDataRestAdapter` for all responses of the *Angular* `$http` service then you can add the `SpringDataRestInterceptor` to the `$httpProvider.interceptors` in an *Angular* configuration block:\n\n```javascript\nmyApp.config(function (SpringDataRestInterceptorProvider) {\n    SpringDataRestInterceptorProvider.apply();\n});\n```\nThe `apply` method will automatically add the `SpringDataRestInterceptor` to the `$httpProvider.interceptors`.\n\n## Dependencies\n\nThe `spring-data-rest` *Angular* module requires the `ngResource` *Angular* module.\n\n## Release notes\n\nCheck them here: [Release notes](https://github.com/guylabs/angular-spring-data-rest/blob/master/RELEASENOTES.md)\n\n## Acknowledgements\n\nWhen I first searched for an *Angular* module for Spring Data REST I just found the marvelous project of Jeremy which is useful if you just use [Spring HATEOAS](http://projects.spring.io/spring-hateoas). So please have a look at his [angular-hateoas](https://github.com/jmarquis/angular-hateoas) project because he gave me the full permissions to use his code base and project structure for this project here. At this point I want to thank him for his nice work.\n\n## License\n\nThis *Angular* module is available under the MIT license.\n\n(c) All rights reserved Guy Brand\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguylabs%2Fangular-spring-data-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguylabs%2Fangular-spring-data-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguylabs%2Fangular-spring-data-rest/lists"}