An open API service indexing awesome lists of open source software.

https://github.com/eperedo/fetch-hooks


https://github.com/eperedo/fetch-hooks

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

> Use the fetch API with react hooks

### Instalation

```bash
yarn add @eperedo/fetch-hooks
```

```bash
npm install @eperedo/fetch-hooks
```

### Usage

```js
import React from 'react';
import { useFetch } from 'fetch-hooks';

const url = 'https://jsonplaceholder.typicode.com/users/1';

function UserProfile() {
const [{ data: user, loading }] = useFetch({ url });

if (loading) {
return

Loading User Profile...
;
}

return

{data.name}

;
}

export default UserProfile;
```