diff --git a/utils/http.ts b/utils/http.ts index 69432b8f0..e294170f7 100644 --- a/utils/http.ts +++ b/utils/http.ts @@ -1,5 +1,4 @@ -import { type RequestInit } from "@deco/deco"; -import { fetchSafe } from "./fetch.ts"; +import { type DecoRequestInit as RequestInit, fetchSafe } from "./fetch.ts"; // Check if DEBUG_HTTP env var is set const DEBUG_HTTP = Deno.env.get("DEBUG_HTTP") === "true"; diff --git a/vtex/utils/intelligentSearch.ts b/vtex/utils/intelligentSearch.ts index 482b33f7a..757d46421 100644 --- a/vtex/utils/intelligentSearch.ts +++ b/vtex/utils/intelligentSearch.ts @@ -1,6 +1,7 @@ import { AppContext } from "../mod.ts"; import { STALE } from "../../utils/fetch.ts"; import type { + PageType, SelectedFacet, SimulationBehavior, Sort, @@ -148,7 +149,19 @@ export const pageTypesFromUrl = async ( segments.map((_, index) => vcsDeprecated["GET /api/catalog_system/pub/portal/pagetype/:term"]({ term: segments.slice(0, index + 1).join("/"), - }, STALE).then((res) => res.json()) + }, STALE).then((res) => res.json()).catch((e) => { + if (e?.status === 400) { + return { + id: null, + name: null, + url: null, + title: null, + metaTagDescription: null, + pageType: "NotFound", + } satisfies PageType; + } + throw e; + }) ), ); };