从 Arrow (localhost) 到模拟器的 HttpRequest

HttpRequest from Arrow (localhost) to emulator

我正在尝试在模拟器中从本地主机中托管的 Arrow 执行 httpRequest。这是我从 API 文档中获得的代码:

    var xhr = Ti.Network.createHTTPClient({
    onload: function onLoad() {
        alert("Loaded: " + this.status + ": " + this.responseText);
    },
    onerror: function onError() {
        alert("Errored: " + this.status + ": " + this.responseText);
    }
});

xhr.open("GET","http://127.0.0.1:8080/api/externa");
var authstr = 'Basic ' + Ti.Utils.base64encode('QM59cPRalcyN6eDMLqiu8HmJJ+47kLOi:');
xhr.setRequestHeader("Authorization", authstr);
xhr.send(); 

我收到状态=0,这意味着警报显示:

Errored: 0 :

如果我 运行 移动网络中的代码或使用节点版本代码来请求相同的 API,一切正常,但使用模拟器则不然。我的防火墙关闭了,我正在使用 Windows 7.

是的,没错,模拟器正在访问他自己的本地主机,正确的方法是使用 http:10.0.2.2:8080 地址