I have REST backend in node and express environment. My service is generating following JSON
[
{ "id": 1, "name": "Action" },
{ "id": 2, "name": "Drama" },
{ "id": 3, "name": "Comedy" },
{ "id": 4, "name": "Romance" }
]
Where ember-data requires JSON in following format
{
"genres": [
{ "id": 1, "name": "Action" },
{ "id": 2, "name": "Drama" },
{ "id": 3, "name": "Comedy" },
{ "id": 4, "name": "Romance" }
]
}
Following is backed code which is generating JSON
all : function(req, res){
res.header('Access-Control-Allow-Origin', "*");
if(connection){
connection.query('SELECT * FROM generes',
function(err, rows, fields){
if(err) throw err;
res.contentType('application/json');
res.send(JSON.stringify(rows));
res.end();
});
}
}
How can I add the resource name in JSON string?