node-quickbooks icon indicating copy to clipboard operation
node-quickbooks copied to clipboard

Warning: a promise was rejected with a non-error

Open gogbajbobo opened this issue 3 years ago • 4 comments

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.

gogbajbobo avatar Mar 13 '21 09:03 gogbajbobo

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 avatar Mar 23 '22 19:03 scole954387

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

scole954387 avatar Mar 23 '22 19:03 scole954387

@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)
        })
    })

gogbajbobo avatar Mar 25 '22 11:03 gogbajbobo

@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

scole954387 avatar Mar 25 '22 22:03 scole954387