Kaynağa Gözat

Partial commit --- News service to fetch data from Punjab kings website [Current issue = CORS]

master
kj1352 4 yıl önce
ebeveyn
işleme
66c7885300
8 değiştirilmiş dosya ile 1592 ekleme ve 1595 silme
  1. +1563
    -1561
      .firebase/hosting.d3d3.cache
  2. +2
    -2
      src/app/app.module.ts
  3. +4
    -1
      src/app/home/home.page.ts
  4. +0
    -25
      src/app/services/data.service.ts
  5. +4
    -4
      src/app/services/news.service.spec.ts
  6. +17
    -0
      src/app/services/news.service.ts
  7. +1
    -1
      src/app/tabs/tabs-routing.module.ts
  8. +1
    -1
      src/app/tabs/tabs.page.html

+ 1563
- 1561
.firebase/hosting.d3d3.cache
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 2
- 2
src/app/app.module.ts Dosyayı Görüntüle

@@ -16,7 +16,7 @@ import { environment } from '../environments/environment';
import { MyHammerConfig } from './hammer-config';
import { HttpClientModule } from '@angular/common/http';

import { DataService } from './services/data.service';
import { NewsService } from './services/news.service';

import { GooglePlus } from '@ionic-native/google-plus/ngx';

@@ -45,7 +45,7 @@ var firebaseConfig = {
StatusBar,
SplashScreen,
GooglePlus,
DataService,
NewsService,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
{ provide: HAMMER_GESTURE_CONFIG, useClass: MyHammerConfig },
],


+ 4
- 1
src/app/home/home.page.ts Dosyayı Görüntüle

@@ -1,7 +1,7 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { IonSlides, ModalController } from '@ionic/angular';
import { Router } from '@angular/router';
import { ChatPage } from '../chat/chat.page';
import { NewsService } from '../services/news.service';

export type INews = {
id: string | number,
@@ -50,9 +50,12 @@ export class HomePage implements OnInit {
constructor(
private router: Router,
private modalController: ModalController,
private newsService: NewsService
) { }

ngOnInit() {
this.newsService.getArticles().then((data) => console.log(data));

this.newsData = [{
id: 1,
image: 'https://www.kxip.in/static-assets/waf-images/c3/b2/7d/16-9/DWWfHZsFg1.jpg',


+ 0
- 25
src/app/services/data.service.ts Dosyayı Görüntüle

@@ -1,25 +0,0 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';

@Injectable({
providedIn: 'root'
})
export class DataService {

constructor(
private http: HttpClient
) { }


getPosts() {
const httpOptions = {
headers: new HttpHeaders({
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
})
};
return this.http.get('https://www.kxip.in/api/flowicsproxy?url=https://live.flowics.com/api/content/0.2/flows/d0184b7bd3e021a4b557d6cb2d33a6ec/posts', httpOptions).toPromise();
}

}


src/app/services/data.service.spec.ts → src/app/services/news.service.spec.ts Dosyayı Görüntüle

@@ -1,13 +1,13 @@
import { TestBed } from '@angular/core/testing';

import { DataService } from './data.service';
import { NewsService } from './news.service';

describe('DataService', () => {
let service: DataService;
describe('NewsService', () => {
let service: NewsService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(DataService);
service = TestBed.inject(NewsService);
});

it('should be created', () => {

+ 17
- 0
src/app/services/news.service.ts Dosyayı Görüntüle

@@ -0,0 +1,17 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';

@Injectable({
providedIn: 'root'
})
export class NewsService {

constructor(
private http: HttpClient
) { }


getArticles() {
return this.http.get('https://www.punjabkingsipl.in/api/listing?entities=4&otherent=1,8021&pgnum=1&inum=10&pgsize=10').toPromise();
}
}

+ 1
- 1
src/app/tabs/tabs-routing.module.ts Dosyayı Görüntüle

@@ -23,7 +23,7 @@ const routes: Routes = [
},
{
path: '',
redirectTo: '/tabs/live',
redirectTo: '/tabs/home',
pathMatch: 'full'
}
];


+ 1
- 1
src/app/tabs/tabs.page.html Dosyayı Görüntüle

@@ -1,7 +1,7 @@
<ion-tabs #tabs (ionTabsDidChange)="setCurrentTab()">
<ion-tab-bar slot="bottom" [ngClass]="{'live' : selectedTab === 'live',
'dark' : selectedTab === 'player-stats'}">
<ion-tab-button tab="home" disabled="true">
<ion-tab-button tab="home">
<ion-icon name="home-outline"></ion-icon>
<ion-icon name="home"></ion-icon>
</ion-tab-button>


Yükleniyor…
İptal
Kaydet