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://dev-web-fm99.mcot.net/wp-json/wp/v2/news?_embed"
    );
  }

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