从woocommerece api获取数据时出现离子错误

时间:2018-10-03 12:49:36

标签: angularjs node.js ionic-framework

我无法发现我做错了什么。我已经安装了woocommerce节点程序包,并且已经使用帮助邮递员应用程序检查了其余的api。

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


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

  WooCommerce: any;

  constructor(public navCtrl: NavController) {

    this.WooCommerce = WC({
        url: "http://localhost/wordpress",
        consumerKey: ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
        consumerSecret: cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    });


   this.WooCommerce.getAsync("products").then((data)=>{
   console.log(data);
    }, (err)=>{
    console.log(err)

    })


  }
}

错误的屏幕截图:

enter image description here

1 个答案:

答案 0 :(得分:1)

更改 this.WooCommerce = WC({ url: "http://localhost/wordpress", consumerKey: ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, consumerSecret: cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx }); this.WooCommerce = WC({ url: "http://localhost/wordpress", consumerKey: "ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", consumerSecret: "cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }); 注意引号。