【发布时间】:2018-08-06 11:20:34
【问题描述】:
我正在使用节点 js 请求模块向网站发送发布请求。查看网站请求后,它使用“表单数据”作为有效负载。页面的内容类型是“application/x-www-form-urlencoded”。我的脚本正在电子应用程序中单击按钮运行。我的代码示例如下:
let options2 = {
method: "POST",
uri: site_url,//predefined
followAllRedirects: true,
headers: {
'Origin': checkout_host,//predefined
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.8',
'Referer': referer//predefined
'User-Agent': UA//predefined
},
formData: {
information that site is requesting
}
request(options2, (err, resp, body) => }
*I end up repeating the code for different information here*
}
在运行我的代码时,这是我遇到的错误,它立即停止:
TypeError: self._form.on is not a function
【问题讨论】:
-
如果将“Content-Type”标头设置为“multipart/form-data”会怎样?
-
@Partik 当我这样做时,我得到了同样的错误。
-
你在 Node 中使用
request模块吗?还是在前端? -
@Partik 节点中的请求模块
标签: javascript node.js reactjs request electron