Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gogbajbobo opened this issue Mar 13, 2021 · 4 comments
Open

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

gogbajbobo opened this issue Mar 13, 2021 · 4 comments

Comments

@gogbajbobo
Copy link

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
Copy link

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
Copy link

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

@gogbajbobo
Copy link
Author

@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
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants