import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Storage } from '@ionic/storage-angular';

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

  constructor(private http: HttpClient) { }

  // getAllNews() {
  //   return this.http.get(
  //     "../assets/api/news-api.json"      
  //   );
  // }
  getAllNews() {
    return this.http.get(
      "https://fm99activeradio.mcot.net/wp-json/wp/v2/news?_embed"
    );
  }

  getNewsDetail(id) {
    let url = 'https://fm99activeradio.mcot.net/'
    const route = url + 'wp-json/wp/v2/' + 'news/' + id + '?_embed';
    return this.http.get(route);
  }

  getAllYoutube() {
    return this.http.get(
       "../assets/api/youtube-data.json"
     // "https://youtube.googleapis.com/youtube/v3/search?part=snippet&channelId=UCfZdHbI3pIN4uselPFzzbOg&maxResults=5&order=date&key=AIzaSyDsRrS_dUxT_3PFaMZIBBdrbl37p_fqrNY"
    );
  }
}
