node-js访问rest api的方法

//npm install node-rest-client --save-dev

var Client = require('node-rest-client').Client
function locate() {
var client = new Client()
var args = {
data: { input: "hello" },
headers: { "Content-Type": "application/json" }
}; // registering remote methods
client.registerMethod("postMethod", "http://192.168.1.122:8082/api/geo/domain", "POST"); client.methods.postMethod(args, function (data, response) {
// parsed response body as js object
console.log(data);
// raw response
console.log(response);
});
}
上一篇:PHP程序员求职经验总结


下一篇:Jeecg心得篇--这个世界不缺程序员,而是缺少匠人和架构师