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 22
33## What is useFetch?
44
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
66
77## Installation:
88
@@ -42,11 +42,61 @@ ReactDOM.render(<App />, document.getElementById('root'));
4242
4343## Demo:
4444
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 )
4647
47- ## Options :
48+ ## Configurations :
4849
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 )
50100
51101## License:
52102
You can’t perform that action at this time.
0 commit comments