[英]NodeJS POST method not working with request module
我包含了 require 模塊並嘗試將數據發布到 php 文件。
代碼: request.post('http://localhost/actions.php?setonline',{user});
沒有錯誤,也沒有不工作。 我有什么問題嗎?
request.post('http://localhost/actions.php?setonline',{user})
正在返回一個stream
並且您沒有處理它的任何事件,這就是您看不到任何輸出的原因。
在任何情況下,您可能想要的是使用回調,並獲得緩沖響應。
request.post('http://localhost/actions.php?setonline',{user}, (err, response, body) => {
console.log(err, response, body);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.