node.js - NodeJS POST method not working with request module
问题描述
I included require module and trying to post data to a php file.
Code: request.post('http://localhost/actions.php?setonline',{user});
There is no error and no not working. Do I something wrong?
解决方案
request.post('http://localhost/actions.php?setonline',{user})
正在返回 astream
并且您没有处理它的任何事件,这就是您看不到任何输出的原因。
在任何情况下,您可能想要的是使用回调,并获得缓冲的响应。
request.post('http://localhost/actions.php?setonline',{user}, (err, response, body) => {
console.log(err, response, body);
});
推荐阅读
- console - Minecraft 控制台收到错误的命令
- solidity - tondev“错误:参数参数(元组)期望名称在......”当使用有效负载参数时
- email - Outlook 特有的暗模式
- python - Python在列表中输入一个水果并统计有多少个单词
- npm - 如何更新 npm 包的依赖项?
- php - 为什么不使用长寿命会话 ID 来代替带有令牌的持久 cookie?
- laravel - 我如何让我的 cascadeOnDelete 在 laravel 中工作
- java - org.mockito.exceptions.misusing.WrongTypeOfReturnValue
- python - 尝试可视化 ScoreCAM 时图形断开值错误
- amazon-web-services - 在 AWS 中管理一次性基础设施作业