Skip to content

mkpartners/node-quickbooks-async

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-quickbooks-async

Seamless Async-Await support for the node-quickbooks package.

This package provides a modern wrapper around node-quickbooks that adds Promise-based functionality to all its methods, allowing you to use async/await syntax while maintaining 100% backward compatibility with original callback-style code.

Why this package?

Unlike other wrappers, node-quickbooks-async uses hybrid methods. This means you don't have to learn a new API—the original method names just "work" with await.

  • Seamless Migration: Switch from node-quickbooks to node-quickbooks-async without changing a single line of code.
  • Hybrid Methods: Methods automatically return a Promise if no callback is provided.
  • Legacy Support: Original callback patterns still work perfectly.
  • Full Metadata Access: All static properties and constants are preserved.

Installation

npm install node-quickbooks-async

Usage

Replace your node-quickbooks require with node-quickbooks-async. The constructor is identical.

const QuickBooks = require('node-quickbooks-async');

const qbo = new QuickBooks(
  consumerKey,
  consumerSecret,
  accessToken,
  tokenSecret,
  realmId,
  useSandbox,
  debug,
  minorversion,
  '2.0', // oauthversion
  refreshToken
);

async function run() {
  try {
    // 1. Seamless Async/Await (Same method names!)
    const info = await qbo.getCompanyInfo(realmId);
    console.log('Company Name:', info.CompanyName);

    // 2. Original Callback Style (Still works)
    qbo.findAccounts({ limit: 5 }, (err, results) => {
      console.log('Got accounts via callback');
    });

    // 3. Explicit Async Suffix (Optional)
    const vendors = await qbo.findVendorsAsync({ limit: 10 });

  } catch (err) {
    console.error('Error:', err);
  }
}

How it works

Every method on the node-quickbooks prototype (e.g., createAccount, findInvoices, reportBalanceSheet) has been wrapped to check its arguments. If the last argument is not a function, the method returns a native Promise.

License

MIT

About

NodeJS client providing Async-Await support for node-quickbooks

Topics

Resources

Stars

Watchers

Forks

Contributors