1
I have a code snippet that I use to consume a API
and use this same chunk in several files. So I created a module to export such a configuration:
'use strict'
// Module to access woocommerce API endpoints
var woocommerceAPI = require('woocommerce-api')
// Load the environment configuration
require('dotenv').config()
module.exports = () => {
return new woocommerceAPI({
url: process.env.URL,
consumerKey: process.env.CONSUMERKEY,
consumerSecret: process.env.CONSUMERSECRET,
version: process.env.VERSION
})
}
When the package instance returns woocommerceAPI
it should contain the function get
, being as follows.
const wc = require('./wc-config')
wc.get('products', (err, data, res) => {
console.log(res)
})
But I only get the message that wc.get
is not a function.