Stefan Atanasov
03/08/2024, 8:33 AMtypesenseClient
in this case is used?
The AggregateError
is I suppose something from node itself when I initialize Typesense on server start. It happened before I added try{} catch{}
blocks in the function.
private async initializeTypesense(): Promise<void> {
try {
if (!typesenseClient)
return console.error({
msg: "initializeTypesense: typesenseClient is not defined"
});
const collections = await typesenseClient?.collections().retrieve();
const collectionsNames = collections?.map(
(collection) => collection.name
);
if (!collectionsNames?.includes(typesenseNewsArticleSchema.name))
await typesenseClient
.collections()
.create(typesenseNewsArticleSchema)
.then((res) => console.log({ res }))
.catch((err) =>
console.log({
msg: "Error while creating News Articles Typesense Schema",
err
})
);
} catch (error) {
console.error({ msg: "initializeTypesense error" });
}
}