Woocommerce api列出了所有现在全部返回的产品

我正在使用节点(js)的woocommerce-api,由于某种原因,无论我尝试这个代码块只保留返回10个产品,而不是整个列表。

有人有build议吗。 提前致谢。

WooCommerce.get('products', function(err, data, res) { if (res !== null) { allItems = JSON.parse(res); } }); 

您应该能够传递参数,比如per_page ,以检索超过默认的10。

尝试:

 WooCommerce.get('products?per_page=50', function(err, data, res) { if (res !== null) { allItems = JSON.parse(res); } }); 

如果你在这里阅读API文档,你会发现你可以提供可选的参数给你的请求来获得所需的结果。

根据这个修改你的要求,并尝试 –

 WooCommerce.get('products?per_page=50', function(err, data, res) { if (res !== null) { allItems = JSON.parse(res); } }); 

这应该返回你50个项目,例如。