0

Retrieve a single product and a single category by id. This is my code:

  this.WooCommerce = WC({
  url: "https://mmarket.ir",
  consumerKey: "ck_bd53%###########cfa",
  consumerSecret: "cs_b9%$##########2ff4",
  wpAPI: true,
  version: 'wc/v2',
});


this.WooCommerce.get('orders/5953', function(err, data, res) {
  console.log('SINGLE ORDER IS: ',res);
});

this.WooCommerce.get('products/5439', function(error, data , res){
  console.log("SINGLE PRODUCT IS: ", res)
});

After executing "npm run browser" or "ionic serve" I get empty result:

home.ts:67 SINGLE PRODUCT IS:  
home.ts:62 SINGLE ORDER IS: 

EMPTY result when retrieve single product and category.

I could easily retrieve single product from woocommerce using rest api in past days but it is not possible from 2 days ago!

I use "Allow CORS: Access-Control-Allow-Origin" & "Allow-Control-Allow-Origin:* " chrom extentions.

Any idea?

sideshowbarker
  • 62,215
  • 21
  • 143
  • 153
Hamid Araghi
  • 370
  • 2
  • 12

1 Answers1

-1

By disabling chrome web security (disable-same-origin-policy) in one instance of chrome running the problem ran away! using this method:

For Windows:

Open the start menu Type windows+R or open "Run" Execute the following command:

chrome.exe --user-data-dir="C://Chrome dev session" --disable-web-security

ref: Disable same origin policy in Chrome

Don't disable chrome web security completely, it will cause to expose security risks. But the only way I could find till now is that.

Hamid Araghi
  • 370
  • 2
  • 12