Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hey @greghains

    Not sure if you’ve managed to do it now but I’ve just encountered the same problem.

    the initial response from the server when making the API call to the products area will have some information in it that includes the count in the text

    The response header does contain the total product count and the total number of pages, presumably based on the per_page you specify. Don’t know what you’re using but I’m using the api through node and the below extracts the product count and page count from the initial response.

    var response = await wooApi.get("products", { 'per_page': 100 });
    var productCount = response.headers['x-wp-total'];
    var pageCount = response.headers['x-wp-totalpages'];
    
    console.log(<code>products: ${productCount}, pages: ${pageCount}</code>);
Viewing 1 replies (of 1 total)