Asm*_*man 3 android node.js nativescript fetch-api laravel-5.2
我一直在尝试使用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);
});
Run Code Online (Sandbox Code Playgroud)
发送到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);
});
Run Code Online (Sandbox Code Playgroud)
当我尝试通过请求模块从localhost:8000/api获取纯node.js的响应.它工作正常.但是现在,我不知道如何使用fetch模块在nativescript中解决这个问题.
相反,localhost使用10.0.2.2(如果使用AVD模拟器)
10.0.2.2 - Special alias to your host loopback interface
(i.e., 127.0.0.1 on your development machine)
Run Code Online (Sandbox Code Playgroud)
对于GenyMotion仿真器,环回地址为10.0.3.2
| 归档时间: |
|
| 查看次数: |
2666 次 |
| 最近记录: |