Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt): pass async-data errors through to client#8521

Merged
pi0 merged 5 commits intomainfrom
fix/hydrate-errors
Nov 2, 2022
Merged

fix(nuxt): pass async-data errors through to client#8521
pi0 merged 5 commits intomainfrom
fix/hydrate-errors

Conversation

@danielroe
Copy link
Member

@danielroe danielroe commented Oct 27, 2022

🔗 Linked issue

resolves nuxt/nuxt#12885

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This PR passes error status/message through to client side. Together with unjs/ofetch#152 and h3js/h3#213 this will enable accessing error.statusCode (which is useful for making decisions regarding 404s, etc.) and will pass a normalised error object through to client.

There will still be some differences between client + server errors because server errors are raw and not normalised with createError.

You can test with:

<template>
  <div>{{ error.message }}</div>
</template>
<script setup>
const { error } = await useFetch('https://jsonplaceholder.typicode.com/404')

onMounted(() => console.log(error.value))
</script>

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added bug Something isn't working 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels Oct 27, 2022
@danielroe danielroe requested a review from pi0 October 27, 2022 09:19
@danielroe danielroe self-assigned this Oct 27, 2022
@codesandbox
Copy link

codesandbox bot commented Oct 27, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@netlify
Copy link

netlify bot commented Oct 27, 2022

Deploy Preview for nuxt3-docs canceled.

Name Link
🔨 Latest commit 79f21bb
🔍 Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/635a891f05b2c500095e6f45

@wobsoriano
Copy link
Member

Finally 😅

@pi0 pi0 merged commit bdacfa6 into main Nov 2, 2022
@pi0 pi0 deleted the fix/hydrate-errors branch November 2, 2022 09:07
@pi0 pi0 mentioned this pull request Nov 3, 2022
@szulcus
Copy link

szulcus commented Nov 3, 2022

I'm very happy about this! ❤️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.x bug Something isn't working 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useAsyncData does not pass errors from server to client-side

4 participants