【问题标题】:Can't get WooCommerce customers by email无法通过电子邮件获得 WooCommerce 客户
【发布时间】:2018-04-02 03:10:20
【问题描述】:

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

"{"code":"rest_no_route","message":"没有找到匹配 URL 和请求方法的路由","data":{"status":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);

【问题讨论】:

    标签: woocommerce woocommerce-rest-api


    【解决方案1】:
    this.wooCommerce.getAsync("customers/email/"+ this.newUser.email).then( (data) => {
        console.log(data);
    }
    

    把这个改成====>>>

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

    【讨论】:

    • 虽然此代码可能会回答问题,但提供有关此代码为何和/或如何回答问题的额外上下文可提高其长期价值。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-24
    • 2022-01-13
    • 1970-01-01
    • 2015-03-01
    • 2018-04-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多