Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

param query per_page not working #99

Open
dainq97 opened this issue Jun 17, 2021 · 1 comment
Open

param query per_page not working #99

dainq97 opened this issue Jun 17, 2021 · 1 comment

Comments

@dainq97
Copy link

dainq97 commented Jun 17, 2021

I have a problem retrieving the products list, i want to return 20 item for request get products. I tried

const WooCommerceRestApi = require("@woocommerce/woocommerce-rest-api").default;

const api = new WooCommerceRestApi({
  url: "http://myurl.com",
  consumerKey: "ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  consumerSecret: "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  version: "wc/v3"
});

api.get("products", {
  per_page: 20
})
  .then((response) => {
       console.log(response.data.length);
  })
  .catch((error) => {
    console.log("Response Data:", error.response.data);
  })
  .finally(() => {
    // Always executed.
  });

but the request doesn't seem to receive per_page=20, it return default 10 items
can anyone help me to solve this problem?
many thanks

@joshpsawyer
Copy link

joshpsawyer commented Jun 25, 2021

Experiencing the same issue, but page param doesn't work for me either.

Actually, my issue isn't related to this but to my host. I'm using WP Engine and something about the way they're caching seems to be dropping query parameters. Regardless, I tried the request through postman with the same issue, so it's not this package.

@quocdai-IT you should send the request in Postman or curl and see if the parameter's respected outside of this package. If not, it's something to do with your host / woocommerce itself.

Update: it was a plugin that was the culprit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants