FacultyCreative / ngActiveResource

Connects business objects and REST web services for Angular.js
255 stars 34 forks source link

Root element in json response #36

Closed richthedev closed 7 years ago

richthedev commented 10 years ago

Our rails API returns a root element in the response: { user: { id: 1, username: "user1" } }

Is there a way to tell ngActiveResource to parse the data correctly?

AlJohri commented 10 years ago

There's work being done to create a custom serializer https://github.com/FacultyCreative/ngActiveResource/issues/18.

If your format is always

{ object: { id: X, attribute: x } }

for single objects

and I assume

{ objects: [{ id: X, attribute: x }] }

for multiple objects.

you can easily hack together a temporary solution by modifying the GET function in lib/angular-resource/base/base.js see https://github.com/FacultyCreative/ngActiveResource/issues/31.

Also the main developers are focused on a TidyUpMission at the moment so Custom Serializers etc. are temporarily on the backburner. Please see https://github.com/FacultyCreative/ngActiveResource/issues/34