Ionic 3 WP-REST API发布请求401(未授权)错误

问题描述 投票:0回答:1

我正在开发一个简单的应用程序,通过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

javascript angular typescript ionic3 woocommerce-rest-api
1个回答
0
投票

您需要一个enter image description here连接,将以下行添加到您的woocommerce init:

https

任何verifySsl: false, queryStringAuth: true 请求都需要post连接。

© www.soinside.com 2019 - 2024. All rights reserved.