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

the client returns an empty error and no data to the callback even though the find request returns data #209

Open
DustinAPI opened this issue Dec 19, 2022 · 0 comments

Comments

@DustinAPI
Copy link

DustinAPI commented Dec 19, 2022

I am attempting to recreate this query with the node-quickbooks

select * from Customer Where CompanyName IN ('customer1', 'customer2')

using this code

qbo.findCustomers(
        [
          { field: 'fetchAll', value: true },
          {
            field: 'CompanyName',
            value: [adminAccounts.name, adminAccounts.locationWithContacts.name],
            operator: 'IN',
          },
        ],
        (error, customers) => {
          if (error) {
            throw new Error(JSON.stringify(error));  //error {} is thrown here
          }
 
          const quickBooksCustomer = customers.QueryResponse.Customer.find((customer) => {
            return (
              customer.CompanyName === adminAccounts.name &&
              customer.Notes.includes(adminAccounts.id)
            );
          });
...

And the terminal tells me that the data is returned.

invoking endpoint: https://sandbox-quickbooks.api.intuit.com/v3/company/xxxxxxx/query?query=select * from customer where CompanyName IN (%27customer 1671214493243%27,%27location-with-contacts 1671214494373%27) startposition 1 maxresults 1000
 
{
  "QueryResponse": {
    "Customer": [
      {
        "Taxable": true,
        "BillAddr": {
          "Id": "598",
          "Line1": "6603 Brennon Inlet",
          "City": "Oklahoma City",
          "Country": "United States of America",
          "CountrySubDivisionCode": "CT",
          "PostalCode": "99887"
        },
        "Notes": "hes.account.id:xxxxxx",
        "Job": false,
        "BillWithParent": false,
        "Balance": 0,
        "BalanceWithJobs": 42.33,
        "CurrencyRef": {
          "value": "USD",
          "name": "United States Dollar"
        },
        "PreferredDeliveryMethod": "Print",
        "domain": "QBO",
        "sparse": false,
        "Id": "241",
        "SyncToken": "0",
        "MetaData": {
          "CreateTime": "2022-12-16T10:15:03-08:00",
          "LastUpdatedTime": "2022-12-16T10:15:04-08:00"
        },
        "FullyQualifiedName": "customer 1671214493243",
        "CompanyName": "customer 1671214493243",
        "DisplayName": "customer 1671214493243",
        "PrintOnCheckName": "customer 1671214493243",
        "Active": true
      },

but the callback receives an empty object in the error parameter.


        (error, customers) => {
          if (error) {
            throw new Error(JSON.stringify(error));  //error {} is thrown here
          }


and if I ignore the error parameter, accessing the data throws an undefined error.

 
       (error, customers) => {
          if (error) {
       //     throw new Error(JSON.stringify(error));  //error {} is thrown here
          }
 
          const quickBooksCustomer = customers.QueryResponse.Customer.find((customer) => {
            return (
              customer.CompanyName === adminAccounts.name &&
              customer.Notes.includes(adminAccounts.id)
            );
          });

TypeError: Cannot read properties of undefined (reading 'Customer')

I believe #132 may be having a related issue.

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