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

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

Merged
merged 5 commits into from Nov 2, 2022
Merged

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 unjs/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

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