成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

javascript - nodejs使用require(’request’)模塊發(fā)送數(shù)據(jù),報(bào)錯(cuò)

瀏覽:90日期:2023-08-26 13:58:25

問題描述

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.});

javascript - nodejs使用require(’request’)模塊發(fā)送數(shù)據(jù),報(bào)錯(cuò)

這是官網(wǎng)上的實(shí)例,但是我這邊報(bào)錯(cuò)。error: Error: Invalid protocol: null不知道什么協(xié)議的原因官方githubrequest

問題解答

回答1:

已解決,應(yīng)該是cnpm的鍋,用npm重新安裝request模塊,成功運(yùn)行了

回答2:

我試了一下,是沒有發(fā)現(xiàn)問題的,你是用webstorm的調(diào)試工具運(yùn)行的嗎? 或者可以嘗試一下重新安裝模塊,再用命令行運(yùn)行試一下。只看到一個(gè)跟你一樣問題的 看 Stack Overflow里面 貼上連接參考一下,還有感覺你的報(bào)錯(cuò)信息也不完整建議貼全一點(diǎn)https://stackoverflow.com/que...

javascript - nodejs使用require(’request’)模塊發(fā)送數(shù)據(jù),報(bào)錯(cuò)

回答3:

是不是 npm 設(shè) proxy 了

回答4:

是:還是:?

標(biāo)簽: JavaScript
相關(guān)文章: