抓取Api:无法从本地主机获取数据

我一直在尝试使用nativescript创build一个android应用程序。我使用获取模块从我的服务器获取响应。当我试图从httpbin.org/get获取响应时,它是可以的。但是当我试图获得响应从我的本地服务器,我得到networking请求失败。 错误。

发送到httpbin.org/get-

return fetchModule.fetch("https://httpbin.org/get").then(response => { return response.text(); }).then(function (r) { console.log(r); }, function (e) { console.log(e); }); 

发送到本地主机:8000 / api-

 return fetchModule.fetch("http://localhost:8000/api").then(response => { return response.text(); }).then(function (r) { console.log(r); }, function (e) { console.log(e); }); 

当我尝试通过请求模块得到localhost:8000 / api中纯node.js的响应时,它运行良好。但是现在,我不知道如何使用fetch模块来解决nativescript中的这个问题。

相反,本地主机使用10.0.2.2 (如果使用AVD模拟器)

 10.0.2.2 - Special alias to your host loopback interface (ie, 127.0.0.1 on your development machine) 

对于GenyMotion仿真器,回送地址是10.0.3.2