在node.js程序上访问github api时请求禁止
我试图运行这个代码,但得到这个错误:
请求由pipe理规则禁止,请确保您的请求有一个用户代理标题
var https = require("https"); var username = 'jquery'; var options = { host: 'api.github.com', path: '/users/' + username + '/repos', method: 'GET' }; var request = https.request(options, function(response){ var body = ''; response.on("data", function(chunk){ body += chunk.toString('utf8'); }); response.on("end", function(){ console.log("Body: ", body); }); }); request.end();
您的options
对象没有headers
选项,描述了user-agent
。 尝试这个:
var options = { host: 'api.github.com', path: '/users/' + username + '/repos', method: 'GET', headers: {'user-agent': 'node.js'} };
- 节点-v57-linux-x64 / grpc_node.node丢失
- jenkins – 节点JS + GitHub集成在Windows 10生成过程中失败
- 如何将文件从Github拖到数字海洋液滴
- 在成功的Travis构build/testing之后,如何将node.js应用程序部署到私有服务器?
- npm安装从git url缺less一些文件
- 是否有可能查询GitHub API的任何回购,用户是一个合作者?
- 将Azure托pipe的DocPad Node.js网站的GitHub更新部署到站点,使站点离线1-2分钟
- 使用Private Repo NPM Package作为依赖源文件需要编译
- GitHub限速防止用户提交历史logging的返回