searchCatalogItems({}) in Typescript SDK returning Invalid BAD_REQUEST

This same exact call seems to be working fine in the Python SDK. Is there something I should be doing different?

My request looks like:

const client = new Client({

environment: Environment.Sandbox,

accessToken: "myAPIKey",

})

export const getCoffeeOfferings = async () => {

  try {

    const response = await client.catalogApi.searchCatalogItems({});

    console.log(response.result);

  } catch(error) {

    console.log(error);

  }

}

My response looks like:

  request: {
    method: 'POST',
    url: 'https://connect.squareupsandbox.com/v2/catalog/search-catalog-items',   
    headers: {
      'user-agent': 'Square-TypeScript-SDK/13.1.0',
      'content-type': 'application/json',
      authorization: 'Bearer myAPIkey',
      'Square-Version': '2021-08-18',
      accept: 'application/json'
    },
    body: { type: 'text', content: '{}' }
  },
  statusCode: 400,
  headers: {
    'content-type': 'application/json',
    'square-version': '2021-08-18',
    vary: 'Origin, Accept-Encoding',
    'x-content-type-options': 'nosniff',
    'x-download-options': 'noopen',
    'x-frame-options': 'SAMEORIGIN',
    'x-permitted-cross-domain-policies': 'none',
    'x-speleo-traceid': 'SFTaWdKWDXeFY',
    'x-xss-protection': '1; mode=block',
    date: 'Thu, 09 Sep 2021 23:39:47 GMT',
    'content-length': '172',
    'strict-transport-security': 'max-age=631152000; includeSubDomains; preload', 
    connection: 'close'
  },
  body: '{"errors":[{"category":"INVALID_REQUEST_ERROR","code":"BAD_REQUEST","detail":"Value is expected to be map[string]interface {}, but received string (line 1, character 4)"}]}',
  result: [Object: null prototype] { errors: [ [Object: null prototype] ] },      
  errors: [
    [Object: null prototype] {
      category: 'INVALID_REQUEST_ERROR',
      code: 'BAD_REQUEST',
      detail: 'Value is expected to be map[string]interface {}, but received string (line 1, character 4)'
    }
  ]
}

Could you share the package-lock.json or yarn.lock file, along with your package.json file?

Hi Bryan,

Thanks for responding.

Here is my

package.json:

{
  "name": "~TODO~",
  "version": "0.0.1",
  "scripts": {
    "dev": "svelte-kit dev",
    "build": "svelte-kit build",
    "preview": "svelte-kit preview",
    "check": "svelte-check --tsconfig ./tsconfig.json",
    "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
    "lint": "prettier --ignore-path .gitignore  --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
    "format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
  },
  "devDependencies": {
    "@sveltejs/kit": "next",
    "@typescript-eslint/eslint-plugin": "^4.19.0",
    "@typescript-eslint/parser": "^4.19.0",
    "eslint": "^7.22.0",
    "eslint-config-prettier": "^8.1.0",
    "eslint-plugin-svelte3": "^3.2.0",
    "prettier": "~2.2.1",
    "prettier-plugin-svelte": "^2.2.0",
    "svelte": "^3.34.0",
    "svelte-check": "^2.0.0",
    "svelte-preprocess": "^4.0.0",
    "tslib": "^2.0.0",
    "typescript": "^4.0.0"
  },
  "type": "module",
  "dependencies": {
    "dotenv": "^10.0.0",
    "square": "^13.1.0"
  }
}

Package-lock.json was too big, so I uploaded here: hastebin

Hi @Bryan-Square, just wondering if you have found anything related?

EDIT: I update created a new SvelteKit app without typescript and it seems to be working fine now?

We created a test app with those dependencies explicitly, and we could not reproduce this issue. Are you saying that after updating the SvelteKit app without typescript that it’s working?

Hi Brian,

That is correct. Appreciate you checking.