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:
| import { Client } from "@bizzkit/search";
const searchClient = new Client({ baseUrl: "http://my-shop.bizzkit.com" });
|
Simple search
For the different type of searches check searching
With the client initialized you can perform a simple search like
| searchClient.products
.getProducts({
segmentId: "b2c-dk-da",
scopeId: "browse",
})
.then(
({ data }) => console.log("DATA:", data),
({ error }) => console.error("ERR:", error.errors)
);
|
or
| 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);
}
|
Authenticated search
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)
);
|