# react-fetch-it-hook

> Fetch with hook in react

Latest version **1.2.0** (published 2021-03-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-fetch-it-hook
pnpm add react-fetch-it-hook
yarn add react-fetch-it-hook
bun add react-fetch-it-hook
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2021-03-29 |
| First published | 2021-03-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Vito Manuguerra |
| Maintainers | softlabfe |

## Links

- npm: https://www.npmjs.com/package/react-fetch-it-hook
- npm.io page: https://npm.io/package/react-fetch-it-hook

## Recent versions

- 1.2.0 (latest) — 2021-03-29
- 1.1.3 — 2021-03-29
- 1.1.2 — 2021-03-29
- 1.1.1 — 2021-03-26
- 1.1.0 — 2021-03-26
- 1.0.6 — 2021-03-26
- 1.0.5 — 2021-03-26
- 1.0.4 — 2021-03-26
- 1.0.3 — 2021-03-26
- 1.0.2 — 2021-03-26
- 1.0.1 — 2021-03-26
- 1.0.0 — 2021-03-05

## README

#REACT FETCH IT HOOK


    yarn add react-fetch-it-hook

##getting started

### add provider

    ReactDOM.render(
        <React.StrictMode>
            <FetchProvider value={{basePath: 'http://demo7542668.mockable.io', logLevel: 'INFO'}}>
                <App/>
            </FetchProvider>
        </React.StrictMode>,
        document.getElementById('root')
    )
    
### fetch example

    interface IBaseResponse {
        body: unknown
    }
    
    interface IHelloResponse extends IBaseResponse {
        body: {
            messagge: string
        }
    }
    
    interface IHelloRequest {
        user: string
    }
    
    export const DumpFetchComponent: React.FC = props => {
    
        // can rename the response with comma
        const {response: helloResponse, error, loading, call} = useFetch<IHelloResponse, IHelloRequest>({
            url: '/{test}',
            method: HttpMethod.POST
        })
    
        useEffect(() => {
            setTimeout(() => {
                call({user: '1'}, {test: 'hello'}, {last: 10})
            }, 1000)
        }, [])
        useEffect(() => {
            console.info('final error ', error)
    
        }, [error])
    
        useEffect(() => {
            console.info('final response', helloResponse)
        }, [helloResponse])
    
        useEffect(() => {
            console.info('loading ', loading ? 'yes' : 'no')
        }, [loading])
    
        return <div> RESPONSE {helloResponse && JSON.stringify(helloResponse)}</div>
    }
    
    
## issues
- works just debug log

---
_Source: https://npm.io/package/react-fetch-it-hook · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
