使用ionic 3创建RSS阅读器应用程序时出现问题

时间:2018-10-18 17:51:49

标签: api ionic-framework ionic3 rss-reader

我正在创建一个应用,该应用允许您按照以下教程-> https://www.youtube.com/watch?v=OKCic9ZQVm8

来阅读RSS feed。

我按照视频中指示的步骤进行操作,但是无法正确阅读RSS feed。我使用的API是https://rss2json.com

代码:

noticies.ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { RssProvider } from '../../providers/rss/rss';

@IonicPage()
@Component({
  selector: 'page-noticies',
  templateUrl: 'noticies.html',
})
export class NoticiesPage {
rssDataArray: any = [];

  constructor(public navCtrl: NavController, public navParams: NavParams, public rssProvider: RssProvider) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad NoticiesPage');
    this.Get_RSS_Data()
  }

  Get_RSS_Data(){
    this.rssProvider.GetRSS().subscribe(
      data => {
        this.rssDataArray = data;
        console.log(data);
      }

    );
  }
}

提供者-> rss-> rss.ts

import { Injectable } from '@angular/core';
    import {Http} from '@angular/http';
    import 'rxjs/add/operator/map';

    @Injectable()
    export class RssProvider {

      constructor(public http: Http) {
        console.log('Hello RssProvider Provider');
      }

      GetRSS(){
        const RSS_URL: any='http://rss.cnn.com/rss/edition.rss';
        const API: any='XXXXXXXXXXXXXX';
        const count: any =20;
        const API_URL: any ='https://api.rss2json.com/v1/api.json';
        const response = this.http.post(API_URL, {'rss_url': RSS_URL,'api_key': API, 'count': count}).map(res => res.json());

        return response;
      }

    }

错误-> https://i.stack.imgur.com/LcFHE.png

0 个答案:

没有答案