Skip to content

Commit 5098ce2

Browse files
Amit DabadeAmit Dabade
authored andcommitted
Merge branch 'master' of https://github.com/amitdabade/react-use-fetch into master
2 parents 669bdb1 + e6dd566 commit 5098ce2

File tree

1 file changed

+54
-4
lines changed

1 file changed

+54
-4
lines changed

README.md

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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

0 commit comments

Comments
 (0)