饭叔的知识整理

superagent

用法:

GET:

var request = require('superagent');

request
.get(url)
.buffer() //注意,使用buffer,可确保superagent生成res.text
.end(function(err, res){
    console.log(res.text);
});

POST:

function saveInfo(info){
    request
    .post('http://127.0.0.1:8888/')
    .set('Content-Type', 'application/json')
    .send(info)
    .end();//即使不要结果也得调用end()
}

参考

https://github.com/request/request
http://visionmedia.github.io/superagent/
https://github.com/pyrsmk/qwest