【发布时间】:2019-02-05 19:56:12
【问题描述】:
我正在开发一个简单的应用程序,通过 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));
})
}
【问题讨论】:
-
这可能意味着您实际上未经授权将数据发布到此 API。您不应该在此请求中传递授权标头吗?
-
如何通过呢?在哪里?
-
你怎么知道 api 正在工作?
-
发布您的
WooCommerce课程。
标签: javascript angular typescript ionic3 woocommerce-rest-api