Skip to content

Commit 6fc3ba6

Browse files
committed
update for new axios version
1 parent 0d126b4 commit 6fc3ba6

File tree

7 files changed

+2190
-17632
lines changed

7 files changed

+2190
-17632
lines changed

package-lock.json

Lines changed: 0 additions & 15659 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@types/react": "^17.0.13",
1212
"@types/react-dom": "^17.0.8",
1313
"@types/react-router-dom": "^5.1.7",
14-
"axios": "^0.21.1",
14+
"axios": "^0.24.0",
1515
"bootstrap": "^4.6.0",
1616
"react": "^17.0.2",
1717
"react-dom": "^17.0.2",

src/components/AddTutorial.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const AddTutorial: React.FC = () => {
2424
};
2525

2626
TutorialDataService.create(data)
27-
.then(response => {
27+
.then((response: any) => {
2828
setTutorial({
2929
id: response.data.id,
3030
title: response.data.title,
@@ -34,7 +34,7 @@ const AddTutorial: React.FC = () => {
3434
setSubmitted(true);
3535
console.log(response.data);
3636
})
37-
.catch(e => {
37+
.catch((e: Error) => {
3838
console.log(e);
3939
});
4040
};

src/components/Tutorial.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ const Tutorial: React.FC<Props> = (props: Props) => {
2222

2323
const getTutorial = (id: string) => {
2424
TutorialDataService.get(id)
25-
.then(response => {
25+
.then((response: any) => {
2626
setCurrentTutorial(response.data);
2727
console.log(response.data);
2828
})
29-
.catch(e => {
29+
.catch((e: Error) => {
3030
console.log(e);
3131
});
3232
};
@@ -49,34 +49,34 @@ const Tutorial: React.FC<Props> = (props: Props) => {
4949
};
5050

5151
TutorialDataService.update(currentTutorial.id, data)
52-
.then(response => {
52+
.then((response: any) => {
5353
console.log(response.data);
5454
setCurrentTutorial({ ...currentTutorial, published: status });
5555
setMessage("The status was updated successfully!");
5656
})
57-
.catch(e => {
57+
.catch((e: Error) => {
5858
console.log(e);
5959
});
6060
};
6161

6262
const updateTutorial = () => {
6363
TutorialDataService.update(currentTutorial.id, currentTutorial)
64-
.then(response => {
64+
.then((response: any) => {
6565
console.log(response.data);
6666
setMessage("The tutorial was updated successfully!");
6767
})
68-
.catch(e => {
68+
.catch((e: Error) => {
6969
console.log(e);
7070
});
7171
};
7272

7373
const deleteTutorial = () => {
7474
TutorialDataService.remove(currentTutorial.id)
75-
.then(response => {
75+
.then((response: any) => {
7676
console.log(response.data);
7777
props.history.push("/tutorials");
7878
})
79-
.catch(e => {
79+
.catch((e: Error) => {
8080
console.log(e);
8181
});
8282
};

src/components/TutorialsList.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ const TutorialsList: React.FC = () => {
2020

2121
const retrieveTutorials = () => {
2222
TutorialDataService.getAll()
23-
.then(response => {
23+
.then((response: any) => {
2424
setTutorials(response.data);
2525
console.log(response.data);
2626
})
27-
.catch(e => {
27+
.catch((e: Error) => {
2828
console.log(e);
2929
});
3030
};
@@ -42,24 +42,24 @@ const TutorialsList: React.FC = () => {
4242

4343
const removeAllTutorials = () => {
4444
TutorialDataService.removeAll()
45-
.then(response => {
45+
.then((response: any) => {
4646
console.log(response.data);
4747
refreshList();
4848
})
49-
.catch(e => {
49+
.catch((e: Error) => {
5050
console.log(e);
5151
});
5252
};
5353

5454
const findByTitle = () => {
5555
TutorialDataService.findByTitle(searchTitle)
56-
.then(response => {
56+
.then((response: any) => {
5757
setTutorials(response.data);
5858
setCurrentTutorial(null);
5959
setCurrentIndex(-1);
6060
console.log(response.data);
6161
})
62-
.catch(e => {
62+
.catch((e: Error) => {
6363
console.log(e);
6464
});
6565
};

src/services/TutorialService.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@ import http from "../http-common";
22
import ITutorialData from "../types/Tutorial";
33

44
const getAll = () => {
5-
return http.get("/tutorials");
5+
return http.get<Array<ITutorialData>>("/tutorials");
66
};
77

88
const get = (id: any) => {
9-
return http.get(`/tutorials/${id}`);
9+
return http.get<ITutorialData>(`/tutorials/${id}`);
1010
};
1111

1212
const create = (data: ITutorialData) => {
13-
return http.post("/tutorials", data);
13+
return http.post<ITutorialData>("/tutorials", data);
1414
};
1515

1616
const update = (id: any, data: ITutorialData) => {
17-
return http.put(`/tutorials/${id}`, data);
17+
return http.put<any>(`/tutorials/${id}`, data);
1818
};
1919

2020
const remove = (id: any) => {
21-
return http.delete(`/tutorials/${id}`);
21+
return http.delete<any>(`/tutorials/${id}`);
2222
};
2323

2424
const removeAll = () => {
25-
return http.delete(`/tutorials`);
25+
return http.delete<any>(`/tutorials`);
2626
};
2727

2828
const findByTitle = (title: string) => {
29-
return http.get(`/tutorials?title=${title}`);
29+
return http.get<Array<ITutorialData>>(`/tutorials?title=${title}`);
3030
};
3131

3232
const TutorialService = {

0 commit comments

Comments
 (0)