javascript - nodejs uses the require('request') module to send data and report an error
女神的闺蜜爱上我
女神的闺蜜爱上我 2017-07-03 11:42:31
0
4
1036
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.
});

This is an example on the official website, but I reported an error here. error: Error: Invalid protocol: null
I don’t know the reason for the protocol
Official githubrequest

女神的闺蜜爱上我
女神的闺蜜爱上我

reply all(4)
阿神

Solved, it should be cnpm’s fault. Use npm to reinstall the request module and it runs successfully

漂亮男人

I tried it and found no problem. Did you use the webstorm debugging tool to run it?
Or you can try reinstalling the module and try running it from the command line.
I only saw one person with the same problem as you. Look in Stack Overflow.
Post the link for reference. I also feel that your error message is incomplete. I suggest you post it in full.
https://stackoverflow.com/que...

为情所困

Has npm set up proxy?

仅有的幸福

Is it: or:?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template