LearningProcesss / boardgamegeekjsclient

Typescript written API wrapper for Boardgamegeek XML2 API
MIT License
18 stars 6 forks source link

Feature request: Search #27

Closed benjick closed 2 years ago

benjick commented 2 years ago

Hey, this lib looks great!

I would like to make a feature request for support the search API.

I tried looking at the source code but it was a very different setup compared to what I'm used to.

Cheers

LearningProcesss commented 2 years ago

Hi, this functionality is part of the newly 1.3.0 release.

Cheers

benjick commented 2 years ago

Thank you for this! Just tried it out, but I'm getting some errors.

Running this code:

import { BggClient } from "boardgamegeekclient";
const client = BggClient.Create();

async function search() {
  const result = await client.search.query({
    type: ["boardgame", "boardgameexpansion"],
    query: "Exit The Game",
    exact: undefined,
  });
  console.log(result);
}

search();

I get the following error:

TypeError: Cannot read properties of undefined (reading 'toString')
    at /bgg-thing/node_modules/boardgamegeekclient/dist/src/query/concrete/GenericQueryBuilder.ts:7:61
    at Array.map (<anonymous>)
    at GenericQueryBuilder.build (/bgg-thing/node_modules/boardgamegeekclient/dist/src/query/concrete/GenericQueryBuilder.ts:7:10)
    at BggSearchClient.<anonymous> (/bgg-thing/node_modules/boardgamegeekclient/dist/src/client/concrete/BggSearchClient.ts:28:42)
    at Generator.next (<anonymous>)
    at /bgg-thing/node_modules/boardgamegeekclient/dist/cjs/client/concrete/BggSearchClient.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/bgg-thing/node_modules/boardgamegeekclient/dist/cjs/client/concrete/BggSearchClient.js:4:12)
    at BggSearchClient.query (/bgg-thing/node_modules/boardgamegeekclient/dist/cjs/client/concrete/BggSearchClient.js:22:16)
    at /bgg-thing/test.ts:6:38
LearningProcesss commented 1 year ago

Thank you for this! Just tried it out, but I'm getting some errors.

Running this code:

import { BggClient } from "boardgamegeekclient";
const client = BggClient.Create();

async function search() {
  const result = await client.search.query({
    type: ["boardgame", "boardgameexpansion"],
    query: "Exit The Game",
    exact: undefined,
  });
  console.log(result);
}

search();

I get the following error:

TypeError: Cannot read properties of undefined (reading 'toString')
    at /bgg-thing/node_modules/boardgamegeekclient/dist/src/query/concrete/GenericQueryBuilder.ts:7:61
    at Array.map (<anonymous>)
    at GenericQueryBuilder.build (/bgg-thing/node_modules/boardgamegeekclient/dist/src/query/concrete/GenericQueryBuilder.ts:7:10)
    at BggSearchClient.<anonymous> (/bgg-thing/node_modules/boardgamegeekclient/dist/src/client/concrete/BggSearchClient.ts:28:42)
    at Generator.next (<anonymous>)
    at /bgg-thing/node_modules/boardgamegeekclient/dist/cjs/client/concrete/BggSearchClient.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/bgg-thing/node_modules/boardgamegeekclient/dist/cjs/client/concrete/BggSearchClient.js:4:12)
    at BggSearchClient.query (/bgg-thing/node_modules/boardgamegeekclient/dist/cjs/client/concrete/BggSearchClient.js:22:16)
    at /bgg-thing/test.ts:6:38

Solved with 1.7.1