在nativescript中使用哪种方法执行http

在nativescript中使用哪种方法执行http,nativescript,Nativescript,我应该使用哪种方法进行http调用:文档不清楚每种方法的优缺点 方法1根据交互式文档第2课第9步 及 从nativescript/nativescript.module导入{NativeScriptModule} 进入app.module 类似于在正常角度下的操作 方法2: 以及使用以下方法: httpModule.getStringhttps://httpbin.org/get 方法3 以及使用以下方法: fetchModule.fetchconfig.apirl+user/+config.

我应该使用哪种方法进行http调用:文档不清楚每种方法的优缺点

方法1根据交互式文档第2课第9步

从nativescript/nativescript.module导入{NativeScriptModule}

进入app.module 类似于在正常角度下的操作

方法2:

以及使用以下方法:

httpModule.getStringhttps://httpbin.org/get

方法3

以及使用以下方法:


fetchModule.fetchconfig.apirl+user/+config.appKey+/login,{method:POST,body:JSON.stringify{username:viewModel.getemail,password:viewModel.getpassword},headers:getCommonHeaders}

第一种方法是使用Angular http服务

就像任何服务一样,它可以被注入。在后台,它调用较低级别的http调用,例如fetch

第二种方法是使用名为http的内部库。不是我的

第三个是http调用api的较低级别、基于承诺的纯本机驱动

这一切都取决于你使用的fw

using import { Http, Headers, Response } from "@angular/http";
const httpModule = require("http");
var fetchModule = require("fetch");