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
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:?