Here's the code snippet I've been working on:
const express = require('express');
const router = express.Router();
const WooCommerceAPI = require('woocommerce-api');
const WooCommerce = new WooCommerceAPI({
url: 'https://example.ro',
consumerKey: 'ck_xxxxxxxxxxxxxxxxx',
consumerSecret: 'cs_xxxxxxxxxxxxxxxx',
wpAPI: true,
version: 'wc/v1'
});
router.get('/', function(req, res) {
WooCommerce.get('products', function(err, data, response) {
console.log(response);
});
});
module.exports = router;
Despite receiving a console log in the terminal, I'm struggling to display the JSON data in the route itself. I attempted using res.json(response)
within the WooCommerce.get function, but encountered an error indicating that res.json is not a function.