1 parent a9acc67 commit 558cd6cCopy full SHA for 558cd6c
1 file changed
02-tours/setup/src/App.js
@@ -6,14 +6,18 @@ import Tours from "./Tours";
6
const url = "https://course-api.com/react-tours-project";
7
function App() {
8
const [tours, setTours] = useState([]);
9
- const [loading, isLoading] = useState(true);
+ const [loading, setLoading] = useState(true);
10
11
const getTours = async () => {
12
- isLoading(true);
13
- const response = await fetch(url);
14
- const tours = await response.json();
15
- isLoading(false);
16
- setTours(tours);
+ try {
+ const response = await fetch(url);
+ const tours = await response.json();
+ setLoading(false);
+ setTours(tours);
17
+ } catch (error) {
18
19
+ console.log(error);
20
+ }
21
};
22
23
useEffect(() => {
0 commit comments