woocommerce / woocommerce-rest-api-js-lib

New JavaScript library for WooCommerce REST API
https://www.npmjs.com/package/@woocommerce/woocommerce-rest-api
MIT License
286 stars 75 forks source link

Wrong generated url get using params (per_page, page) #80

Open SolWinArg opened 4 years ago

SolWinArg commented 4 years ago

Describe the bug When requesting data to the WooComerce REST API with params the generated link is wrongly created.

To Reproduce Make an api call with like this: WooCommerce.get("products", { per_page : 99, page: 1 })... // continues // Inside the callback... console.log(response) // "response" being the list of 99 products in page 1

The url generated is: http://example.com/wp-json/wc/v3/products?page=1&per_page=99&function%20()%7Breturn%20this.filter(a)%7D=undefined

The result of console.log(response) is "undefined"

Expected behavior There should be an object containing the 99 prods of page 1, among other important data.

I have

SolWinArg commented 4 years ago

Update Found bug on file 'woocommerce-rest-api/index.js' at the commented screen below..

image

It appears that the "replace" method is not working propperly...

vedanshujain commented 4 years ago

Looks like this issue is related to https://github.com/woocommerce/woocommerce-rest-api-js-lib/ so moving it there.