# react-fetch-as

> React Fetcher Component

Latest version **0.1.5** (published 2016-12-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-fetch-as
pnpm add react-fetch-as
yarn add react-fetch-as
bun add react-fetch-as
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2016-12-25 |
| First published | 2016-12-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | aquz |

## Links

- npm: https://www.npmjs.com/package/react-fetch-as
- Repository: https://github.com/aquz/react-fetch-as
- Homepage: https://github.com/aquz/react-fetch-as#readme
- Issues: https://github.com/aquz/react-fetch-as/issues
- npm.io page: https://npm.io/package/react-fetch-as

## Dependencies (2)

- [react-clone](https://npm.io/package/react-clone.md) ^1.0.0
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.11.6

## Recent versions

- 0.1.5 (latest) — 2016-12-25
- 0.1.4 — 2016-12-25
- 0.1.3 — 2016-12-24
- 0.1.2 — 2016-12-24
- 0.1.1 — 2016-12-24
- 0.1.0 — 2016-12-23

## README

# React Fetch As Component
## Install
```
npm install --save react-fetch-as
```

## Example

After response, children component (`<Slider/>`) will be rendered with "photos" prop, which will contain data from response.
```javascript
import React, { Component } from 'react';
import Fetch from 'react-fetch-as';

class FetcherExample extends Component {
  render() {
    return (
      <Fetch from="http://example.org/photos" as="photos">
        <Slider/>
      </Fetch>
    );
  }
}
```

You can nested `<Fetch/>` components. `<Slider/>` receive "photos" and "images" prop.
```javascript
import React, { Component } from 'react';
import Fetch from 'react-fetch-as';

class NestedExample extends Component {
  render() {
    return (
      <Fetch from="http://example.org/photos" as="photos">
        <Fetch from="http://example.org/images" as="images">
          <Slider/>
        </Fetch>
      </Fetch>
    );
  }
}
```

## Props

Name | Description | Is required | Default
------------ | ------------- | ------------- | -------------
from | URL of the resource you want to fetch. | yes | -
as | Name of the prop, which will be passed to the children component. | no | data
options | Fetch options (https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch/fetch#Parameters) |  no | `{}`
toJson | If `true` response will be parsed to object.  | no | `true`
spinner | React component or string. Will be displayed while loading. | no | `null`
onError | Callback on catch error. | no | -
onSuccess | Callback on success. | no | -

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