Created
May 30, 2012 08:52
-
-
Save bullfight/2834685 to your computer and use it in GitHub Desktop.
Using HATEOAS and Backbone.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"_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