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

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

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

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

Conversation

@danielroe

@danielroedanielroe commented Oct 27, 2022

Copy link
Copy Markdown
Member

🔗 Linked issue

resolvesnuxt/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 } =awaituseFetch('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.

@danielroedanielroe 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 pi0October 27, 2022 09:19
@danielroedanielroe self-assigned this Oct 27, 2022
@codesandbox

Copy link
Copy Markdown

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

@netlify

netlifyBot commented Oct 27, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commit79f21bb
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/635a891f05b2c500095e6f45

Comment threadpackages/nuxt/src/app/composables/asyncData.ts Outdated
@wobsoriano

Copy link
Copy Markdown
Member

Finally 😅

pi0
pi0 approved these changes Nov 2, 2022
@pi0
pi0 merged commit bdacfa6 into mainNov 2, 2022
@pi0
pi0 deleted the fix/hydrate-errors branch November 2, 2022 09:07
@pi0pi0 mentioned this pull request Nov 3, 2022
@szulcus

Copy link
Copy Markdown

I'm very happy about this! ❤️

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

Labels

3.xbugSomething isn't working🍰 p2-nice-to-havePriority 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

@danielroe@wobsoriano@szulcus@pi0