File tree Expand file tree Collapse file tree 1 file changed +54
-4
lines changed Expand file tree Collapse file tree 1 file changed +54
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## What is useFetch?
4
4
5
- React hook to fetch data from network, with some additional awesome features.
5
+ useFetch is open source reusable react custom hook for making http requests with ease and built-in configurations
6
6
7
7
## Installation:
8
8
@@ -42,11 +42,61 @@ ReactDOM.render(<App />, document.getElementById('root'));
42
42
43
43
## Demo:
44
44
45
- [ Demo] ( https://codesandbox.io/s/github/amitdabade/react-use-fetch-demo )
45
+ [ Demo] ( https://codesandbox.io/s/github/amitdabade/react-use-fetch-demo )
46
+ [ Storybook] ( https://amitdabade.github.io/react-use-fetch )
46
47
47
- ## Options :
48
+ ## Configurations :
48
49
49
- url : _ string_
50
+ ** GET**
51
+ ```
52
+ useFetch({
53
+ url: "https://jsonplaceholder.typicode.com/todos/1"
54
+ });
55
+ ```
56
+
57
+ ** POST**
58
+ ```
59
+ useFetch({
60
+ url: "https://jsonplaceholder.typicode.com/posts",
61
+ method: "POST",
62
+ body: JSON.stringify({
63
+ "userId": 1,
64
+ "id": 1,
65
+ "title": "sunt aut facere",
66
+ "body": "quia et suscipit"
67
+ })
68
+ });
69
+ ```
70
+
71
+ ** HEADERS**
72
+ ```
73
+ useFetch({
74
+ url: "https://jsonplaceholder.typicode.com/posts",
75
+ headers: {
76
+ 'Accept': 'application/json',
77
+ 'Content-Type': 'application/json'
78
+ }
79
+ });
80
+ ```
81
+
82
+ ** Default Config**
83
+ ```
84
+ const config = {
85
+ delay: 0,
86
+ retry: 0,
87
+ refetchInterval: 0,
88
+ refetch: Infinity,
89
+ responseType: "text",
90
+ };
91
+
92
+ useFetch({
93
+ url: "https://jsonplaceholder.typicode.com/posts"
94
+ }, config);
95
+ ```
96
+
97
+ ** Custom Config**
98
+
99
+ [ Demo] ( https://amitdabade.github.io/react-use-fetch/?path=/story/advance--delay )
50
100
51
101
## License:
52
102
You can’t perform that action at this time.
0 commit comments