Created
September 14, 2013 19:27
-
-
Save guo-yu/6564844 to your computer and use it in GitHub Desktop.
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 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