I'm looking for best-practise styles for wrapping a REST API in a light-weight JavaScript client.
In the past I've seen libraries which are implemented in a style like:
var request = new SearchRequest(apikey);
request.query = "search term";
request.send(function(results) {
console.log(results);
});
Or that embrace HTTP more explicitly like:
api.get("search", "search term", function(results) {
console.log(results);
});
api.post("comment", comment, function(results) {
console.log(results);
});
Or that wrap at an even higher level:
api.search("search term", function(results) {
console.log(results);
});
api.createComment(comment, function(results) {
console.log(results);
});
What good examples of modern JavaScript client libraries wrapping REST APIs have you seen recently. Not worried about implementation details, just the API design.
Thanks!