• Resolved yonish3

    (@yonish3)


    I’m trying to start work with WooCommerce API – Node.js Client, which looks very straightforward.

    But when I copy a simple example from WooCommerce official website, I get the following error:

    TypeError: WooCommerce.get(…).then is not a function
    Here is the code:

    
    var WooCommerceAPI = require('woocommerce-api');
    
    var WooCommerce = new WooCommerceAPI({
      url: 'https://somewebsite.com/',
      consumerKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      consumerSecret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
      wpAPI: true,
      version: 'wc/v1'
    });
    
    WooCommerce.get("products/1359")
      .then((response) => {
        console.log(response.data);
      })
      .catch((error) => {
        console.log(error.response.data);
      });
    

    API documents and NPM package:
    https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-a-product
    https://www.npmjs.com/package/woocommerce-api

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to fix error ‘WooCommerce.get(…).then is not a function’?’ is closed to new replies.