{"action":"created","issue":{"url":"https://api.github.com/repos/guylabs/angular-spring-data-rest/issues/20","repository_url":"https://api.github.com/repos/guylabs/angular-spring-data-rest","labels_url":"https://api.github.com/repos/guylabs/angular-spring-data-rest/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/guylabs/angular-spring-data-rest/issues/20/comments","events_url":"https://api.github.com/repos/guylabs/angular-spring-data-rest/issues/20/events","html_url":"https://github.com/guylabs/angular-spring-data-rest/issues/20","id":124327899,"number":20,"title":"How to chain resources calls","user":{"login":"sydneyhenrard","id":5309640,"avatar_url":"https://avatars.githubusercontent.com/u/5309640?v=3","gravatar_id":"","url":"https://api.github.com/users/sydneyhenrard","html_url":"https://github.com/sydneyhenrard","followers_url":"https://api.github.com/users/sydneyhenrard/followers","following_url":"https://api.github.com/users/sydneyhenrard/following{/other_user}","gists_url":"https://api.github.com/users/sydneyhenrard/gists{/gist_id}","starred_url":"https://api.github.com/users/sydneyhenrard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sydneyhenrard/subscriptions","organizations_url":"https://api.github.com/users/sydneyhenrard/orgs","repos_url":"https://api.github.com/users/sydneyhenrard/repos","events_url":"https://api.github.com/users/sydneyhenrard/events{/privacy}","received_events_url":"https://api.github.com/users/sydneyhenrard/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/guylabs/angular-spring-data-rest/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":{"login":"guylabs","id":1892848,"avatar_url":"https://avatars.githubusercontent.com/u/1892848?v=3","gravatar_id":"","url":"https://api.github.com/users/guylabs","html_url":"https://github.com/guylabs","followers_url":"https://api.github.com/users/guylabs/followers","following_url":"https://api.github.com/users/guylabs/following{/other_user}","gists_url":"https://api.github.com/users/guylabs/gists{/gist_id}","starred_url":"https://api.github.com/users/guylabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guylabs/subscriptions","organizations_url":"https://api.github.com/users/guylabs/orgs","repos_url":"https://api.github.com/users/guylabs/repos","events_url":"https://api.github.com/users/guylabs/events{/privacy}","received_events_url":"https://api.github.com/users/guylabs/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-12-30T09:54:00Z","updated_at":"2016-03-17T21:46:03Z","closed_at":null,"body":"I would like to call several resources like that:\r\n\r\n```\r\nPOST http://lolcahost:54000/api/v1/portfolios\r\nPATCH http://lolcahost:54000/api/v1/portfolios/1\r\nGET http://lolcahost:54000/api/v1/portfolios/1/evaluate\r\nGET http://lolcahost:54000/api/v1/portfolios/1\r\nGET http://lolcahost:54000/api/v1/portfolios/1/summaries\r\nProcess the output\r\n```\r\n\r\nI wrote that code but I am not sure it's the correct way to use `SpringDataRestAdapter`. I also have an issue with one of the processed response that does not have a _resources object.\r\n\r\n```\r\n// POST http://lolcahost:54000/api/v1/portfolios\r\nvar myHttpPromise = $http.post('http://localhost:54000/api/v1/portfolios', {});\r\nSpringDataRestAdapter.process(myHttpPromise)\r\n    .then(function (processedResponse) {\r\n        // PATCH http://lolcahost:54000/api/v1/portfolios/1\r\n        var self = processedResponse._links.self.href;\r\n        var data = {};\r\n        return SpringDataRestAdapter.process($http.patch(self, data));\r\n    })\r\n    .then(function (processedResponse) {\r\n    \t// GET http://lolcahost:54000/api/v1/portfolios/1/evaluate\r\n        var resources = processedResponse._resources(\"self/:id\", {id: \"evaluate\"});\r\n        return SpringDataRestAdapter.process(resources.get());\r\n    })\r\n    .then(function (processedResponse) {\r\n    \t// GET http://lolcahost:54000/api/v1/portfolios/1\r\n        console.log(processedResponse);\r\n        // ERROR processedResponse does not have a _resources property\r\n        var resources = processedResponse._resources(\"self\");\r\n        return SpringDataRestAdapter.process(resources.get());\r\n    .then(function (processedResponse) {\r\n\t    // GET http://lolcahost:54000/api/v1/portfolios/1/summaries\r\n        return processedResponse._resources('summaries');\r\n    })\r\n    .then(function (summaries) {\r\n    \t// Process the output\r\n        console.log(summaries);\r\n    }, function (response) {\r\n        console.log(response);\r\n        console.log(response.data.error);\r\n        logger.error(response.data.error);\r\n    });\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/guylabs/angular-spring-data-rest/issues/comments/198097227","html_url":"https://github.com/guylabs/angular-spring-data-rest/issues/20#issuecomment-198097227","issue_url":"https://api.github.com/repos/guylabs/angular-spring-data-rest/issues/20","id":198097227,"user":{"login":"markgargan","id":1690750,"avatar_url":"https://avatars.githubusercontent.com/u/1690750?v=3","gravatar_id":"","url":"https://api.github.com/users/markgargan","html_url":"https://github.com/markgargan","followers_url":"https://api.github.com/users/markgargan/followers","following_url":"https://api.github.com/users/markgargan/following{/other_user}","gists_url":"https://api.github.com/users/markgargan/gists{/gist_id}","starred_url":"https://api.github.com/users/markgargan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markgargan/subscriptions","organizations_url":"https://api.github.com/users/markgargan/orgs","repos_url":"https://api.github.com/users/markgargan/repos","events_url":"https://api.github.com/users/markgargan/events{/privacy}","received_events_url":"https://api.github.com/users/markgargan/received_events","type":"User","site_admin":false},"created_at":"2016-03-17T21:46:02Z","updated_at":"2016-03-17T21:46:02Z","body":"Hey Guy,\r\n\r\n      Could I ask you a question if you have time? \r\n\r\n<img width=\"919\" alt=\"screen shot 2016-03-17 at 21 02 07\" src=\"https://cloud.githubusercontent.com/assets/1690750/13862169/632b9bbe-ec89-11e5-8168-1d9b6d1e02ed.png\">\r\n\r\nI'm using SpringDataRestAdapter to interact with my spring data rest api. From the screen shot you can see that I've just loaded all the questions and I'm attempting to load their answers (one-to-many) relationship. In the debug window the _embeddedItems array is an array of Questions with _links to each questions answers. I'm trying to prompt SpringDataRestAdapter to autoload the answers by passing 'answers' as an argument to the processWithPromise call but to no avail.\r\n\r\nThe urls look like http://localhost:8080/api/questions http://localhost:8080/api/question/1/answers\r\n\r\nThe Question.loadAnswers(question) call is commented out... It works in that it loads the question's answers but I felt I was using the framework incorrectly.\r\n\r\nHere is the method\r\n\r\n```\r\nQuestion.loadAnswers = function (question) {\r\n\r\n            question.answers = question.answers? question.answers : [];\r\n\r\n            angular.forEach(question._links.answers, function (answerLink) {\r\n                var deferred = $http.get(answerLink);\r\n                return SpringDataRestAdapter.processWithPromise(deferred).then(function (data) {\r\n                    question.answers = data._embeddedItems;\r\n                });\r\n            });\r\n        };\r\n```\r\n\r\nCongratulations on an excellent piece of coding Guy! I've also posted this question up on stackoverflow in case the issue is with my understanding of promises as opposed to how to use the framework :)\r\n\r\nhttp://stackoverflow.com/questions/36072090/springdatarestadapter-load-child-resources\r\n\r\nThanks, Mark."}}