URL: /users/
Method: POST
Request Data:
{
"user": {
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe"
}
}
Response Data:
{
"user": {
"id": "1",
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe"
}
}
URL: /users/123
Method: GET
Request Data: NOTHING
Response Data:
{
"user": {
"id": "123",
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe"
}
}
URL: /users/
Method: GET
Request Data: NOTHING
Response Data:
{
"users": [
{
"user": {
"id": "1",
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe"
}
},
{
"user": {
"id": "2",
"email": "[email protected]",
"first_name": "Jane",
"last_name": "Doe"
}
}
]
}
Example: store.query('user', { sort: 'first_name', gender: 'male' });
URL: /users?gender=male&sort=first_name
Method: GET
Request Data: NOTHING
Response Data:
{
"users": [{
"id": "1",
"email": "[email protected]",
"first_name": "Adam",
"last_name": "Doe",
"gender": "male"
}, {
"id": "20",
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe",
"gender": "male"
}]
}
Example: store.queryRecord('user', { first_name: 'John' })
URL: /users?first_name=John
Method: GET
Request Data: NOTHING
Response Data:
{
"user": {
"id": "1",
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe"
}
}
Example:
store.findRecord('user', 1).then(user => {
user.set('first_name', "Jane");
return user.save();
});
URL: /users/1
Method: PUT
Request Data:
{
"user": {
"id": "1",
"email": "[email protected]",
"first_name": "Jane",
"last_name": "Doe"
}
}
Response Data:
{
"user": {
"id": "1",
"email": "[email protected]",
"first_name": "Jane",
"last_name": "Doe"
}
}
Examples
store.findRecord('user', 1).then(function(user) {
user.deleteRecord();
user.get('isDeleted'); // => true
user.save(); // => DELETE to /users/1
});
// OR
store.findRecord('user', 2).then(function(user) {
user.destroyRecord(); // => DELETE to /users/2
});
URL: /users/2
Method: DELETE
Request Data: NOTHING
Response Data: NOTHING
- https://stackoverflow.com/questions/14922623/what-is-the-complete-list-of-expected-json-responses-for-ds-restadapter#
- Ember Data 2.18 https://github.com/emberjs/data/blob/master/tests/integration/adapter/rest-adapter-test.js 3 Updating documentation with the default expected API responses. · Issue #3257