json - Sails.js return generated API in a root object -
i'm trying build simple api using sails.js in accordance json:api format. can utilize ember.js without having modify adapter.
i have used design generator in sails, so:
sails generate api posts
but base of operations resource @ http://127.0.0.1:1337/posts
gives response such:
[ { "id": 1, "createdat": "2014-11-08t14:45:23.328z", "updatedat": "2014-11-08t14:45:23.328z", "title": "example post", "body": "this test" } ]
but want base of operations object response this:
{ "posts": [ { "id": 1, "createdat": "2014-11-08t14:45:23.328z", "updatedat": "2014-11-08t14:45:23.328z", "title": "example post", "body": "this test" } ] }
any ideas how can in ember.js?
edit: i'm using ember info data store , adapter.
so after looking around haven't found specific reply question, how figured out.
looking sails.js blueprints generates responses directory api. in here there ok.js
file handles serving of info 200 response.
file: api/responses/ok.js
.
there several homecoming lines following:
return res.jsonx(data);
as have 1 resource in api changed code to:
return res.jsonx({ "posts": info });
this wraps info in root object ember info expects default.
json rest ember.js sails.js
No comments:
Post a Comment