首页 >社区问答列表 >javascript - nodejs使用require('request')模块发送数据,报错

javascript - nodejs使用require('request')模块发送数据,报错

var request = require('request');
request('http://www.baidu.com', function (error, response, body) {
    console.log('error:', error); // Print the error if one occurred
    console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
    console.log('body:', body); // Print the HTML for the Google homepage.
});

这是官网上的实例,但是我这边报错。error: Error: Invalid protocol: null
不知道什么协议的原因
官方githubrequest

  • 漂亮男人
  • 漂亮男人    2017-07-03 11:44:313楼

    我试了一下,是没有发现问题的,你是用webstorm的调试工具运行的吗?
    或者可以尝试一下重新安装模块,再用命令行运行试一下。
    只看到一个跟你一样问题的 看 Stack Overflow里面
    贴上连接参考一下,还有感觉你的报错信息也不完整建议贴全一点
    https://stackoverflow.com/que...

    +0添加回复

  • 回复