Skip to content

Commit

Permalink
Improve asyncData error in search.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Jan 10, 2025
1 parent 6455642 commit eed90eb
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions frontend/src/pages/search.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import {
createError,
definePageMeta,
navigateTo,
showError,
Expand Down Expand Up @@ -128,15 +127,14 @@ await useAsyncData(
*/
document.getElementById("main-page")?.scroll(0, 0)
const res = await fetchMedia()
if (!res) {
return showError(
createError(
fetchingError.value ?? "Fetch media did not return anything"
)
)
}
if ("requestKind" in res) {
return showError(res)
const error = !res
? (fetchingError.value ?? "Fetch media error") // middleware in SSR returned an error
: "requestKind" in res // fetchMedia returned a `FetchingError`
? res
: null
if (error) {
return showError(error)
}
return res
},
Expand Down

0 comments on commit eed90eb

Please sign in to comment.