Skip to content

Instantly share code, notes, and snippets.

@bullfight
Created May 30, 2012 08:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bullfight/2834685 to your computer and use it in GitHub Desktop.
Save bullfight/2834685 to your computer and use it in GitHub Desktop.
Using HATEOAS and Backbone.js
var Order = Backbone.Model.extend({
});
var HalModel = Backbone.Model.extend({
url: function() {
return get("_links").self;
},
});
parse: function(response) {
this.url = response._links.self;
delete response._links;
return response;
}
[
{
"_links": {
"self": "/orders/123"
}
"name": "Order #123",
"date": "2012/02/23"
},
{
"_links": {
"self": "/orders/6666"
}
"name": "Order #666",
"date": "2012/03/01"
},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment