问:错误:获取粉笔者的个人资料时出错。(永久移动)
似乎它重定向到https以获取JSON以获得配置文件信息。
答:要修复工作区中的此错误,我必须同时需要http和https模块,并将所有内容更改profile.js为https,除了 http.STATUS_CODES:
var EventEmitter = require(“ events”)。EventEmitter;
var http = require(“ http”);
var https = require(“ https”);
var util = require(“ util”);
[...]
//连接到API URL(https://teamtreehouse.com/username.json)
var request = https.get(“ https://teamtreehouse.com/” +用户名+“ .json”,function(response){
var body =“”;
if(response.statusCode!== 200){
request.abort();
//状态码错误
profileEmitter.emit(“ error”,new Error(“获取配置文件的错误。” +用户名+“。(” + http.STATUS_CODES [response.statusCode] +“)”));
}
[...]