feat(poc): test something

This commit is contained in:
Björn Meyer 2023-07-17 12:00:48 +02:00
parent 2ee6394d27
commit 744243c3d8

View File

@ -168,20 +168,53 @@ export async function requestSeoUrl(
page: number = 1, page: number = 1,
limit: number = 1 limit: number = 1
): Promise<SeoURLResultSW | undefined> { ): Promise<SeoURLResultSW | undefined> {
console.log(handle);
try { try {
const testing = handle.replace('cms/', '').replace('product/', '').replace('search/', ''); const FirstCriteria = {
const criteria = { page: page,
limit: limit,
filter: [
{
type: 'multi',
// @ts-ignore
operator: 'or',
queries: [
{
type: 'equals',
field: 'seoPathInfo',
value: handle + '/'
},
{
type: 'equals',
field: 'seoPathInfo',
value: handle
}
]
}
]
};
// @ts-ignore
const firstResult = await apiInstance.invoke('readSeoUrl post /seo-url', FirstCriteria);
if (firstResult.total && firstResult.total > 0) {
return firstResult;
}
const lastPart = handle.split('/').pop() + '';
console.log(lastPart);
const SecondCriteria = {
page: page, page: page,
limit: limit, limit: limit,
filter: [ filter: [
{ {
type: 'contains', type: 'contains',
field: 'seoPathInfo', field: 'seoPathInfo',
value: testing value: lastPart
} }
] ]
}; };
return await apiInstance.invoke('readSeoUrl post /seo-url', criteria);
return await apiInstance.invoke('readSeoUrl post /seo-url', SecondCriteria);
} catch (error) { } catch (error) {
if (error instanceof ApiClientError) { if (error instanceof ApiClientError) {
console.error(error); console.error(error);