0.1.13 • Published 5 years ago

react-use-http v0.1.13

Weekly downloads
5
License
-
Repository
-
Last release
5 years ago

Need to fetch some data? Try this one out.

Examples

  • Code Sandbox Example

Installation

yarn add react-usefetcher

Usage

Stateless

import useFetch from 'react-usefetch'

function App() {
  const [data, loading, error] = useFetch('https://example.com')
  return error ? (
    'Error!'
  ) : loading ? (
    'Loading!'
  ) : (
    <code>
      <pre>{data}</pre>
    </code>
  )
}

Options

OptionDescription
optionsThis is exactly what you would pass to the normal js fetch

Option Usage

const options = {
  method: 'POST'
}
const [data, loading, error] = useFetch(url, options)