This package has been deprecated

Author message:

moved to package: use-http

react-use-http

0.1.13 • Public • Published

useFetch

🐶 A React hook for making http requests

Need to fetch some data? Try this one out.

Examples

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

Option Description
options This is exactly what you would pass to the normal js fetch

Option Usage

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

/react-use-http/

    Package Sidebar

    Install

    npm i react-use-http

    Weekly Downloads

    0

    Version

    0.1.13

    License

    none

    Unpacked Size

    674 kB

    Total Files

    17

    Last publish

    Collaborators

    • alex-cory