Error fetching data API WooCommerce [Ionic 3 + WooCommerce Wordpress]

-1

I can not fetch the product list

home.ts

import { Component } from '@angular/core';
import { NavController, AlertController } from 'ionic-angular';
import * as WC from 'woocommerce-api';

import { ProdutoDetalhePage } from './../produto-detalhe/produto-detalhe';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  woocommerce: any;
  products: any[];

  constructor(public navCtrl: NavController, private alertCtrl: AlertController) {

    this.woocommerce = WC({
      url: "http://localhost/apiLoja/",
      consumerKey: "ck_fd2de11f1df4eb5d24c5f9491cb422a89433f71f",
      consumerSecret: "cs_b1dc8a3227fce5ff09f4a49ff633b024080c4b9f",
      wpAPI: true,
      version: "wc/v2"
    });

    this.woocommerce.getAsync("products").then((data) => {
      console.log(data.body);
    }, (err) => {
      console.log(err)
    })  
}    
  openProdDestaque(id, nome) :void {
     this.navCtrl.push(ProdutoDetalhePage, { id_product: id, nome_product: nome });
  }    
}

and when I run this error appears

    
asked by anonymous 05.01.2019 / 18:35

0 answers