1const wpapi = require('wpapi')
2
3let site = new wpapi.discover('https://your-site.com'); // Let wpwpi discover the routes of your site
4site.then(function(site){
5 site.auth({
6 username: 'woo_rest_username',
7 password: 'woo_rest_password'
8 })
9})
10
11let woocommerce = site.namespace('wc/v3'); // woocommerce endpoint
12
13// Get the latest 10 products
14woocommerce.products().perPage(10).embed().then(products => {
15 // your code
16})