rest - Extracting data from angularJS $resource -


I have a problem using Angel's $ processing service. Because my API sends a full response (headers, etc.) , As well as an error field in the data object, I need to get a specific object from the response. It is quite simple with the $ http service, but I do not understand these resources with the $ resource service how to get. Down $ http is working.

  $ http ({method: 'GET', url: 'http://api.discussorama.com/v1/topics', header: {' x-ap-secret ':' Xxx ',' authorization ':' xxx ',' content-type ':' application / x-www-form-urlencoded '}}). Then (function (feedback) {console.log (feedback); $ scope.topics = response.data.topics;});   

And this is my unsuccessful attempt with unsafe requests:

  var topic = $ resource ('http: //api.discussorama com / v1 {'X-Api-secret': 'xxx', 'authorization': '/': 'id', {id: '@id'}, {query: {isArray: false, method: 'GET', header: Xxx ',' content-type ':' application / x-www-form-urlencoded '}}}); Var response = topic.kudi (); $ Realm Subject = response. Subject; Console.log (feedback);   

EDIT: After updating the above code I am getting into the console.

  f {$ promise: object, $ solution: wrong, get $: function, $ save: function, $ query: functionâ |? | $$ Promise: Object $ Hull: True Error: False Subject: Array [10] __Pooto__: f   

Although I change the console log:

  Console.log (response.topics);   

Console just returns:

  undefined   

Where am I wrong with this? If it helps in the link of the page in question then

You are not promising that $ resources Hand back It should be handled like a $ http call on you

  var topic = $ resource ('http://api.discussorama.com/v1/topics/id', {id: '@id'}, {query: {isArray: false} , Method: 'GET', header: {'X-AP-secret': 'xxx', 'authorization': 'xxx', 'content-type': 'application / x-www-form-urlencoded'}}} }); Var response = topic.kudi (); Pledge $ Promise Then (function (data) {$ scope.topics = data. Subject; // changed data.data.topics to data.topics});    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -