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

https://github.com/wizyma/react-fetch

React component that integrate the fetch api inspired by apollo-client
https://github.com/wizyma/react-fetch

fetch-api javascript react

Last synced: 4 months ago
JSON representation

React component that integrate the fetch api inspired by apollo-client

Awesome Lists containing this project

README

        

# react-fetch

[![Build Status](https://travis-ci.org/Wizyma/react-fetch.svg?branch=master)](https://travis-ci.org/Wizyma/react-fetch)
[![codecov](https://codecov.io/gh/Wizyma/react-fetch/branch/master/graph/badge.svg)](https://codecov.io/gh/Wizyma/react-fetch)

React component that integrate the fetch api inspired by apollo-client

## Usage
```javascript
// by default the GET method is used
import React, { Component, Fragment } from 'react'
import Fetch from 'react-fetch'
import MyErrorComponent from './error-component'
import LoadingComponent from './loading'

class MyComponent extends Component {
render() {
return(

My Fetch component will be a child who will load asynchronously the data !



{({ error, data, loading }) => {
if(error) return
if(loading) return

if(data) {
return (
data.map(({ id, title, body }) => (


{title}


{body}



))
)
}
}}


)
}
}
```

You can use all the `http` verbs. The Fetch component has optionals parameters such as `credentials` and `headers`.

Do not hesitate to make a pull request or make some suggestions.
PR are welcome :heart: