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

TypeError: argument entity is required #79

Open darrylmorley opened 4 years ago

darrylmorley commented 4 years ago

Hi,

I'm getting the error 'TypeError: argument entity is required'

Any idea what this relates to?

This is my code@

import WooCommerceRestApi from "@woocommerce/woocommerce-rest-api";

const api = new WooCommerceRestApi({
  url: process.env.WP_API,
  consumerKey: process.env.WOO_CONSUMER_KEY,
  consumerSecret: process.env.WOO_CONSUMER_SECRET,
  version: 'wc/v3'
})

// Get FAB Defense Items
export const getFabProducts = async () => {
  api
    .get("products", { per_page: 10 })
    .then(res => console.log(res.data))
    .catch(err => console.warn(err))
}
JohnMarsden24 commented 3 years ago

Hey Darryl, could potentially be a problem with how your environmental variables are being brought in, check my comment here and give it a go: https://github.com/woocommerce/woocommerce-rest-api-js-lib/issues/62#issuecomment-804961623