我在这里使用Nativescript来构建移动应用程序。这里有错误。在我使用Visual Studio 2017进行ASP.Net MVC 5开发中,可以使用很好$http.get().then(),但在Nativescript中则不能。
请参见下面的代码:
import { Component, OnInit } from "@angular/core";
import { HttpClient } from '@angular/common/http';
@Component({
selector: "Home",
moduleId: module.id,
templateUrl: "./home.component.html",
styleUrls: ["./home.component.css"]
})
export class HomeComponent implements OnInit {
constructor(private http: HttpClient) {
}
ngOnInit(): void {
this.http.get('https://somewebsite.com',
{
params: { 'sorter': '', 'isAscending': 'true', 'searchString': '', 'currentPage': '1', 'itemsPerPage': '300' },
headers: {
"Authorization": "Basic encryptedcodehere"
}
}).then(function (response) {
var theData = JSON.parse(response.data);
if (theData.Data != null && theData.Data.length > …Run Code Online (Sandbox Code Playgroud)