Return destructured data only if existing on layout

This commit is contained in:
2022-06-14 11:58:54 +02:00
parent 6873ad6a66
commit 2831600f57

View File

@@ -47,6 +47,7 @@
}) })
</script> </script>
<Switcher isOver={!!$page.params.location && !!$page.params.photo} /> <Switcher isOver={!!$page.params.location && !!$page.params.photo} />
<slot /> <slot />
@@ -61,6 +62,7 @@
<SVGSprite /> <SVGSprite />
<script context="module" lang="ts"> <script context="module" lang="ts">
import type { LoadEvent, LoadOutput } from '@sveltejs/kit' import type { LoadEvent, LoadOutput } from '@sveltejs/kit'
import { fetchAPI } from '$utils/api' import { fetchAPI } from '$utils/api'
@@ -149,6 +151,7 @@
} }
`) `)
if (res) {
const { data } = res const { data } = res
const filteredContinents = data.continents.filter((cont: any) => cont.countries.length) const filteredContinents = data.continents.filter((cont: any) => cont.countries.length)
@@ -166,4 +169,9 @@
}, },
} }
} }
return {
status: 500,
}
}
</script> </script>