Skip to content

Commit 7be6d89

Browse files
authoredMar 3, 2022
docs: Extend simple example to handle failed request (TanStack#3322)
1 parent 3e8f499 commit 7be6d89

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎examples/simple/src/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from "react";
33
import ReactDOM from "react-dom";
44
import { QueryClient, QueryClientProvider, useQuery } from "react-query";
55
import { ReactQueryDevtools } from "react-query/devtools";
6+
import axios from "axios";
67

78
const queryClient = new QueryClient();
89

@@ -16,9 +17,9 @@ export default function App() {
1617

1718
function Example() {
1819
const { isLoading, error, data, isFetching } = useQuery("repoData", () =>
19-
fetch(
20+
axios.get(
2021
"https://api.github.com/repos/tannerlinsley/react-query"
21-
).then((res) => res.json())
22+
).then((res) => res.data)
2223
);
2324

2425
if (isLoading) return "Loading...";

0 commit comments

Comments
 (0)
Please sign in to comment.