Skip to content

Fetching more than 10 products #1

@MartinConde

Description

@MartinConde

Somehow I can only get 10 products. Did some research and found a few solutions for normal WordPress posts/pages but nothing for the WooCommerce api. Would be nice to have some instructions on how to change this limit in the readme or even an option to set it in the Gatsby config ;)

Edit: Got it working but this doesn't feel like the way it is supposed to be but yeah here it is in case anybody has the same issue:

Change:

// Fetch Node and turn our response to JSON
  const fetchNodes = async (fieldName) => {
    const res = await WooCommerce.getAsync(fieldName);
    return JSON.parse(res.toJSON().body);
  };

to

// Fetch Node and turn our response to JSON
  const fetchNodes = async (fieldName) => {
    const res = await WooCommerce.getAsync('products?per_page=100');
    return JSON.parse(res.toJSON().body);
  };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions