Skip to content

Commit

Permalink
fix(roadiz): serialize web response error
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelodelain committed Apr 23, 2024
1 parent a938e9b commit ac7932d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 3 additions & 4 deletions composables/use-roadiz-web-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { joinURL } from 'ufo'
export async function useRoadizWebResponse<T>(path?: string) {
path = joinURL('/', path || useRoute().path)

const fetch = useRoadizFetchFactory()
const { data } = await useAsyncData(async () => {
try {
const fetch = useRoadizFetchFactory()
const response = await fetch.raw<RoadizWebResponse>('/web_response_by_path', {
method: 'GET',
query: {
Expand All @@ -18,9 +18,8 @@ export async function useRoadizWebResponse<T>(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
Expand Down
4 changes: 4 additions & 0 deletions playground/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
// const response = await useRoadizFetch<RoadizNodesSources>('/common_content')
//
// console.log('response.data', response.data.value)
// const webResponse = await useRoadizWebResponse('/')
//
// console.log('webResponse', webResponse)
</script>

<template>
Expand Down

0 comments on commit ac7932d

Please # to comment.