Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/amitdabade/react-use-fetch
Browse files Browse the repository at this point in the history
…into master
  • Loading branch information
Amit Dabade authored and Amit Dabade committed Jan 27, 2022
2 parents 669bdb1 + e6dd566 commit 5098ce2
Showing 1 changed file with 54 additions and 4 deletions.
58 changes: 54 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## What is useFetch?

React hook to fetch data from network, with some additional awesome features.
useFetch is open source reusable react custom hook for making http requests with ease and built-in configurations

## Installation:

Expand Down Expand Up @@ -42,11 +42,61 @@ ReactDOM.render(<App />, document.getElementById('root'));

## Demo:

[Demo](https://codesandbox.io/s/github/amitdabade/react-use-fetch-demo)
[Demo](https://codesandbox.io/s/github/amitdabade/react-use-fetch-demo)
[Storybook](https://amitdabade.github.io/react-use-fetch)

## Options:
## Configurations:

url : _string_
**GET**
```
useFetch({
url: "https://jsonplaceholder.typicode.com/todos/1"
});
```

**POST**
```
useFetch({
url: "https://jsonplaceholder.typicode.com/posts",
method: "POST",
body: JSON.stringify({
"userId": 1,
"id": 1,
"title": "sunt aut facere",
"body": "quia et suscipit"
})
});
```

**HEADERS**
```
useFetch({
url: "https://jsonplaceholder.typicode.com/posts",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
```

**Default Config**
```
const config = {
delay: 0,
retry: 0,
refetchInterval: 0,
refetch: Infinity,
responseType: "text",
};
useFetch({
url: "https://jsonplaceholder.typicode.com/posts"
}, config);
```

**Custom Config**

[Demo](https://amitdabade.github.io/react-use-fetch/?path=/story/advance--delay)

## License:

Expand Down

0 comments on commit 5098ce2

Please sign in to comment.