小编Eug*_*ene的帖子

角度:属性“ then”在“可观察”类型上不存在

我在这里使用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)

nativescript angular

0
推荐指数
1
解决办法
579
查看次数

标签 统计

angular ×1

nativescript ×1