javascript - Node.JS 请求模块回调未触发

标签 javascript node.js http-post

我使用 Node.js 的请求模块运行此代码

var hsKey    = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
var hsForm   = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
var hsHost   = "https://docs.google.com/"
var url = hsHost + "forms/d/" + hsForm + "/formResponse"

var form = {
    "entry.129401737": pointsAvg,
    "entry.2000749128": hiddenNeurons,
    "submit": "Submit",
    "formkey": hsKey
};

request.post({
    url: url,
    form: form
}, function (err, res, body) {
    console.log("Sent data");
});

我尝试仅使用标准 Node.JS 库运行上述代码,但无济于事。回调函数永远不会被触发,请求也不会通过。我不知道为什么。

最佳答案

我相信我已经找到了自己问题的答案。问题似乎是我没有在 Node.js 事件循环中分配任何时间来允许执行请求。

关于javascript - Node.JS 请求模块回调未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35573641/

相关文章:

javascript - Angular Directive(指令)监视变量未触发

android - 如何不向服务器发布任何内容但不使其为空

ios - Alamofire 和 completionHandler 的使用

node.js - 使用 AXIOS (Node.js) 在请求之间保留 cookie

node.js - 如何在终端重启mongodb?

node.js - 如何在 LoopBack 4 中进行数据库迁移

javascript - 向 Office 加载项发送请求

javascript - Canvas 中的事件

javascript - 新日期作为 react 关键 Prop ?

javascript - 从 img 标签创建一个文件对象