这篇文章主要介绍了关于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 add
var 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);
}
} );以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!
相关推荐:
以上就是Node.js使用superagent模拟GET/POST的请求的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号