相关疑难解决方法(0)

TypeError:请求路径包含非转义字符,我该如何解决这个问题

/*Making http request to the api (Git hub)
create request
parse responce
wrap in a function
*/
var https = require("https");

var username = 'lynndor';
//CREATING AN OBJECT
var options = {
    host: 'api.github.com',
    path: ' /users/'+ username +'/repos',
    method: 'GET'
};

var request = https.request(options, function(responce){
    var body = ''
    responce.on("data", function(chunk){
        body += chunk.toString('utf8')
    });
    responce.on("end", function(){
        console.log("Body", body);
    });
});
request.end();
Run Code Online (Sandbox Code Playgroud)

我试图创建一个git hub api的请求,目的是获取指定的列表存储库,但我不断收到上述错误,请帮忙

github node.js

22
推荐指数
4
解决办法
3万
查看次数

标签 统计

github ×1

node.js ×1