无法通过电子邮件获得 WooCommerce 客户
Can't get WooCommerce customers by email
当我进行 API 调用以通过邮件地址获取用户时,出现错误:
"{"code":"rest_no_route","message":"No route was found matching the URL and request method","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);
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);
}
当我进行 API 调用以通过邮件地址获取用户时,出现错误:
"{"code":"rest_no_route","message":"No route was found matching the URL and request method","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);
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);
}