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

TypeError: Cannot convert undefined or null to object #186

Open
scroll17 opened this issue Oct 4, 2021 · 0 comments
Open

TypeError: Cannot convert undefined or null to object #186

scroll17 opened this issue Oct 4, 2021 · 0 comments

Comments

@scroll17
Copy link

scroll17 commented Oct 4, 2021

I call this:

  qbo.findAccounts('', function (_, accounts) {
    accounts.QueryResponse.Account.forEach({ limit: 5, }, function (account) {
      console.log(account.Name);
    });
  });

Then i get error:

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at /home/user/Code/node-quickbooks/index.js:2498:27
    at tryCatcher (/home/user/Code/node-quickbooks/node_modules/bluebird/js/main/util.js:24:31)
    at Promise._settlePromiseFromHandler (/home/user/Code/node-quickbooks/node_modules/bluebird/js/main/promise.js:454:31)
    at Promise._settlePromiseAt (/home/user/Code/node-quickbooks/node_modules/bluebird/js/main/promise.js:530:18)
    at Promise._settlePromises (/home/user/Code/node-quickbooks/node_modules/bluebird/js/main/promise.js:646:14)
    at Async._drainQueue (/home/user/Code/node-quickbooks/node_modules/bluebird/js/main/async.js:177:16)
    at Async._drainQueues (/home/user/Code/node-quickbooks/node_modules/bluebird/js/main/async.js:187:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/user/Code/node-quickbooks/node_modules/bluebird/js/main/async.js:15:14)

I checking line node-quickbooks/index.js:2498 and i debug return data in callback and i saw Array with request results.

The cause of the problem:

  1. in module.request passing 3 arguments to callback
  2. after module.requestPromise = Promise.promisify(module.request)
  3. and after promise resolve we get array with body and req

Promise.promisify convert arguments to array if length > 2.
This cause of error,

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

1 participant