apisdk.js
Build a SDK from API document
Get Started
var api = new APISDK([
'POST /articles',
'GET /articles/:id',
'PUT /articles/:id',
'DELETE /articles/:id'
], {
'host': '/api',
'promise': Promise,
'http': function(params) { console.log(params); }
});
var id = 123;
api.articles(id).get({ token: 789 });
var inc = 0;
var nextArticle = api.articles(function() { return inc++; });
nextArticle.get();
nextArticle.get();
var asyncParam = new Promise(function(resolve){ setTimeout(resolve, 1000, 123); });
api.articles(asyncParam).get();
Friendly with RESTful API
var currentUserId = 123;
var user = api.users(currentUserId);
user.get();
var order = user.orders(123);
order.get();
order.payment.post();
order.rating.post();
order.cancel.post();
order.refunding.post();
Install
bower install apisdk
<script src="/bower_components/apisdk/apisdk.js"></script>