Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error type is useApiData is a FetchError #38

Conversation

mattmess1221
Copy link
Contributor

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSDoc annotations)
  • 🐞 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)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The error type in useApiData is incorrect. It's actual type is a NuxtError with the data type dependent on whether client: true is set. If client: true, data is the response data from the API. Otherwise it is set to what looks like a IFetchError.

πŸ“ Checklist

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

@netlify
Copy link

netlify bot commented Aug 25, 2023

βœ… Deploy Preview for nuxt-api-party ready!

Name Link
πŸ”¨ Latest commit 120f6a3
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt-api-party/deploys/64f08d50d5374500081f082c
😎 Deploy Preview https://deploy-preview-38--nuxt-api-party.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mattmess1221 mattmess1221 changed the title fix: Make error type in useAsyncData conditional fix: Make error type in useApiData conditional Aug 25, 2023
@johannschopplich
Copy link
Owner

Good catch! And great work. Thank you very much! Will review later. Just wanna send some flowers. 🌻

src/runtime/utils.ts Outdated Show resolved Hide resolved
playground/nuxt.config.ts Outdated Show resolved Hide resolved
src/runtime/composables/useApiData.ts Outdated Show resolved Hide resolved
src/runtime/composables/useApiData.ts Outdated Show resolved Hide resolved
@johannschopplich johannschopplich changed the title fix: Make error type in useApiData conditional fix: conditional error type for useApiData Aug 25, 2023
@mattmess1221 mattmess1221 force-pushed the bugfix/async-data-error-type branch from 31972d0 to e87a789 Compare August 25, 2023 20:39
@mattmess1221 mattmess1221 marked this pull request as draft August 28, 2023 15:02
@mattmess1221 mattmess1221 force-pushed the bugfix/async-data-error-type branch from e87a789 to 42c3a5d Compare August 28, 2023 15:27
@mattmess1221 mattmess1221 force-pushed the bugfix/async-data-error-type branch from 42c3a5d to 120f6a3 Compare August 31, 2023 12:53
@mattmess1221 mattmess1221 marked this pull request as ready for review August 31, 2023 12:54
@johannschopplich
Copy link
Owner

Do you think this will this still be relevant with #44?

@mattmess1221
Copy link
Contributor Author

I've made changes to be more minimal. With #44, the types should be more reflective of what they are at runtime. There is an exception of course if there's a transport error in the request or some other bug causing an exception.

@mattmess1221 mattmess1221 changed the title fix: conditional error type for useApiData fix: error type is useApiData is a FetchError Aug 31, 2023
@johannschopplich
Copy link
Owner

Wonderful!

@johannschopplich johannschopplich merged commit 8e4a1ae into johannschopplich:main Aug 31, 2023
@mattmess1221 mattmess1221 deleted the bugfix/async-data-error-type branch March 18, 2024 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants