Skip to content

docs: Extend simple example to handle failed request #3322

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

Merged
merged 2 commits into from
Mar 3, 2022

Conversation

ASchwad
Copy link
Contributor

@ASchwad ASchwad commented Feb 20, 2022

Hey there,
I recently stumpled across a misunderstanding of the library and the referenced simple example.
Since the example contains an error handling with respect to the UI, it should also correctly recognize occurring errors. As mentioned in the docs, fetch and other clients do not throw by default an error - so I added the error handling to the example within the result handler.

@vercel
Copy link

vercel bot commented Feb 20, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tanstack/react-query/D47AHsyRqnYHw1HkhqAN263QtxHj
✅ Preview: https://react-query-git-fork-aschwad-patch-1-tanstack.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 20, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 99284e5:

Sandbox Source
tannerlinsley/react-query: basic Configuration
tannerlinsley/react-query Configuration
tannerlinsley/react-query PR

@TkDodo
Copy link
Collaborator

TkDodo commented Feb 26, 2022

I would want to keep the simple example as simple as possible (minimal lines of code). fetch has this unfortunate spec that 4xx and 5xx are not treated as failed promises. Maybe it would be better to just use axios or ky for this example?

@ASchwad
Copy link
Contributor Author

ASchwad commented Mar 2, 2022

Fair point. I changed the PR to use axios instead of fetch

@TkDodo
Copy link
Collaborator

TkDodo commented Mar 3, 2022

interesting that we had axios in the dependencies already 😅

@codecov
Copy link

codecov bot commented Mar 3, 2022

Codecov Report

Merging #3322 (99284e5) into master (b44c213) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3322   +/-   ##
=======================================
  Coverage   96.47%   96.47%           
=======================================
  Files          45       45           
  Lines        2271     2271           
  Branches      639      639           
=======================================
  Hits         2191     2191           
  Misses         77       77           
  Partials        3        3           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b44c213...99284e5. Read the comment docs.

@TkDodo TkDodo merged commit 7be6d89 into TanStack:master Mar 3, 2022
@tannerlinsley
Copy link
Collaborator

🎉 This PR is included in version 4.0.0-alpha.20 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tannerlinsley
Copy link
Collaborator

🎉 This PR is included in version 3.34.17 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants