Skip to content

Instantly share code, notes, and snippets.

@guo-yu
Created September 14, 2013 19:27
Show Gist options
  • Save guo-yu/6564844 to your computer and use it in GitHub Desktop.
Save guo-yu/6564844 to your computer and use it in GitHub Desktop.
var sdk = require('sdk');
// init a API
var demo = new sdk({
read: {
url: '/demo/read/{{name}}',
method: 'get'
},
update: {
url: '/demo/update',
method: 'post'
}
},{
server: 'http://abc.com'
});
// run demo
// 实际请求 -> http://abc.com/demo/read/123
demo.read({
name: 123, // 会替换掉placeholder
headers: {
// 如有需要自己加
},
// 如果是post的话写form里,对get无效
// form: {
// }
},function(err, result){
console.log(err);
console.log(result.response);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment