Skip to content

Search Client

The @bizzkit/ecommerce-search is an npm package that allows for directly searching from the browser with Ecommerce Search.

Setup

Install the package and initialize the client pointing to the correct URL for the Bizzkit Ecommerce Search Host:

1
2
3
import { Client } from "@bizzkit/search";

const searchClient = new Client({ baseUrl: "http://my-shop.bizzkit.com" });

For the different type of searches check searching

With the client initialized you can perform a simple search like

1
2
3
4
5
6
7
8
9
searchClient.products
  .getProducts({
    segmentId: "b2c-dk-da",
    scopeId: "browse",
  })
  .then(
    ({ data }) => console.log("DATA:", data),
    ({ error }) => console.error("ERR:", error.errors)
  );

or

1
2
3
4
5
6
7
8
9
try {
  const result = await searchClient.products.getProducts({
    segmentId: "b2c-dk-da",
    scopeId: "browse",
  });
  console.log("DATA:", result.data);
} catch (error) {
  console.error("ERR;", error.errors);
}

For more details check authenticated search

searchClient.products
  .getProducts({
    segmentId: "b2c-dk-da",
    scopeId: "browse",
    authenticationToken: "<JWT Token>",
  })
  .then(
    ({ data }) => console.log("DATA:", data),
    ({ error }) => console.error("ERR:", error.errors)
  );