【问题标题】:per_page is not type of integer. Woocommerce REST API Node.jsper_page 不是整数类型。 Woocommerce REST API Node.js
【发布时间】:2021-12-09 19:20:35
【问题描述】:

我正在使用带有 react native 的 Woocommerce rest api。我正在尝试获取所有类别的列表,但我最多获得 10 个项目。

const WooCommerce = new WooCommerceRestApi({url: "xxxxxs", // Your store URL 
ssl: true,
consumerKey: "xxxxx", // Your consumer secret
consumerSecret: "xxxxxx", // Your consumer secret
wpAPI: true, // Enable the WP REST API
integration version: "wc/v3", // WooCommerce WP REST API version
queryStringAuth: true,})

const categories = await WooCommerce.get( "products/categories?per_page=50")
console.log(categories)

我收到了这样的回复:

【问题讨论】:

    标签: javascript wordpress react-native woocommerce woocommerce-rest-api


    【解决方案1】:

    你需要这样传递参数:

    ...
    parameters = {}
    parameters[per_page] = 1
    
    categories = await WooCommerce.get("products/categories/", params=parameters)
    

    【讨论】:

      猜你喜欢
      • 2020-05-12
      • 1970-01-01
      • 1970-01-01
      • 2019-02-05
      • 2018-08-28
      • 1970-01-01
      • 2018-10-22
      • 1970-01-01
      • 2017-11-19
      相关资源
      最近更新 更多