我一直在尝试使用nativescript创建一个
Android应用程序.我正在使用fetch模块从我的服务器获取响应.当我试图从httpbin.org/get获得响应时,它没关系.但是当我试图获得响应时从我的本地服务器,我收到网络请求失败.错误.
发送到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);
});
发送到localhost: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中解决这个问题.