无法通过电子邮件获得WooCommerce客户

时间:2018-02-18 21:08:02

标签: woocommerce woocommerce-rest-api

当我通过邮件地址进行API调用以获取用户时,我收到错误:

  

" {"代码":" rest_no_route","消息":"未找到与网址和请求方法匹配的路由&#34 34;,"数据" {"状态":404}}"

/products//orders/等所有其他来电都没有问题。永久链接设置中的漂亮链接已激活。

this.WooCommerce = WC({
  url: 'http://............./', 
  consumerKey: 'ck_xxxxxxxxxx', 
  consumerSecret: 'cs_xxxxxxxxxxxxxx', 
  wpAPI: true, 
  queryStringAuth: true,
  verifySsl: true,
  version: 'wc/v2' 

checkEmail(){

let validEmail = false;

let reg = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

if(reg.test(this.newUser.email)){
  //email looks valid

  this.wooCommerce.getAsync("customers/email/"+ this.newUser.email).then( (data) => {
    console.log(data);

1 个答案:

答案 0 :(得分:1)

this.wooCommerce.getAsync("customers/email/"+ this.newUser.email).then( (data) => {
    console.log(data);
}

将此更改为====&gt;&gt;&gt;

this.wooCommerce.getAsync("customers?email="+ this.newUser.email).then( (data) => {
    console.log(data);
}