diff --git a/composables/use-roadiz-web-response.ts b/composables/use-roadiz-web-response.ts index 0954fd1..cef064d 100644 --- a/composables/use-roadiz-web-response.ts +++ b/composables/use-roadiz-web-response.ts @@ -4,9 +4,9 @@ import { joinURL } from 'ufo' export async function useRoadizWebResponse(path?: string) { path = joinURL('/', path || useRoute().path) - const fetch = useRoadizFetchFactory() const { data } = await useAsyncData(async () => { try { + const fetch = useRoadizFetchFactory() const response = await fetch.raw('/web_response_by_path', { method: 'GET', query: { @@ -18,9 +18,8 @@ export async function useRoadizWebResponse(path?: string) { return { webResponse: response._data, alternateLinks } } catch (error) { - console.error('Error=', error) - - return { error } + // @ts-ignore cannot know the error type + return { error: createError(error) } } }) const webResponse = data.value?.webResponse diff --git a/playground/pages/index.vue b/playground/pages/index.vue index c012fd8..ec5351d 100644 --- a/playground/pages/index.vue +++ b/playground/pages/index.vue @@ -4,6 +4,10 @@ // const response = await useRoadizFetch('/common_content') // // console.log('response.data', response.data.value) + +// const webResponse = await useRoadizWebResponse('/') +// +// console.log('webResponse', webResponse)