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.
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-quickbookstonode-quickbooks-asyncwithout 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.
npm install node-quickbooks-asyncReplace 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);
}
}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.
MIT