这篇文章主要介绍了关于node.js使用superagent模拟get/post的请求,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
示例代码:
var superagent = require('superagent');superagent.get("http://localhost:8091/user/all?requsername=admin&reqpasswd=654321") .end( (err, res)=> { if (err) { console.log("出错:" + err); } else { console.log(res.text); } } );// user addvar url = "http://localhost:8091/user/update"superagent.post(url) .type("form") .send({ id: '5', fullname: '刘德华', username: '8839001', passwd: '111111', branch: '123001', rights: '3', memo: '依然范特西', requsername: 'admin', reqpasswd: '654321' }) .end( (err, res)=> { if (err) { console.log("出错:" + err); } else { console.log(res.text); } } );
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注!
相关推荐:
js获取页面元素距离浏览器工作区顶端的距离
react request.js函数封装
以上就是node.js使用superagent模拟get/post的请求的详细内容。
