我正在开发一个简单的应用程序,通过wp-rest api在Wordpress(woocommerce)中创建用户。但是当我尝试创建新客户时,它会在控制台中显示401 Unauthorized错误。继承人是我的请求代码。
signup(){
let customerData = {
customer : {}
}
customerData.customer = {
"email": this.newUser.email,
"first_name": this.newUser.first_name,
...
"billing_address": {
"first_name": this.newUser.first_name,
...
},
"shipping_address": {
"first_name": this.newUser.first_name,
...
}
}
if(this.billing_shipping_same){
this.newUser.shipping_address = this.newUser.shipping_address;
}
this.WooCommerce.postAsync('customers', customerData).then( (data) => {
console.log(JSON.parse(data.body));
})
}
顺便说一句,关键客户和秘密是正确的qazxsw poi