mcohen01 / node-quickbooks

nodejs client for Intuit's Quickbooks API
332 stars 235 forks source link

Warning: a promise was rejected with a non-error #174

Open gogbajbobo opened 3 years ago

gogbajbobo commented 3 years ago

With Node.js v14 (14.6.0 in my case) any unsuccess query results in "Warning: a promise was rejected with a non-error". This is due to err is not the Error instance in https://github.com/mcohen01/node-quickbooks/blob/master/index.js#L2498.

scole954387 commented 2 years ago

I'm getting the same thing.

qbo.findAccounts(function (error, accounts) { if (!error) { accounts.QueryResponse.Account.forEach(function (account) { console.log(account.Name); }); } else { console.log("error", error); } });

results in: (node:5525) Warning: a promise was rejected with a non-error: [object Object]

and console log: { warnings: null, intuitObject: null, fault: { error: [ [Object] ], type: 'AUTHENTICATION' }, report: null, queryResponse: null, batchItemResponse: [], attachableResponse: [], syncErrorResponse: null, requestId: null, time: 1648061963290, status: null, cdcresponse: [] }

scole954387 commented 2 years ago

@gogbajbobo Did you figure it out? I'm having same problem as you can see from my comment above.

gogbajbobo commented 2 years ago

@scole954387 I use a wrapper for every QBO request, like this:

    return new Promise((resolve, reject) => {
        return qbo.findAccounts({ Name: 'AccountName' }, (err, data) => {
            return err ? reject(new Error(JSON.stringify(err))) : resolve(data)
        })
    })
scole954387 commented 2 years ago

@gogbajbobo Great thanks! I ended up using the exact same thing once I remembered I had followed along with a youtube playlist and had the code already that worked.😀

This is the youtube series here. If you can get past the bad background music and no audio it's a decent series for showing how to work with this package and the api. There's a lot left out and some code was changed off camera but all in all it helped me a lot and I'm a newbie to react/node. https://www.youtube.com/watch?v=ycZ38qgxNUc