Getting Started

Installation & basic usage

Installation

Axios is a peer dependency (prerequisite) and it has to be installed

NPM

$ npm i react-use-api axios

Yarn

$ yarn add react-use-api axios

Usage

With ApiProvider

import React from 'react'
import ReactDom from 'react-dom'
import useApi, { ApiProvider } from 'react-use-api'

import App from './App'

// there is only one props "context", which is must given for SSR,
// client side can omit it
ReactDom.render(
  <ApiProvider>
    <App />
  </ApiProvider>,
  document.getElementById('root')
)

Basic Usage

Parameters

Types

Code

Config

The config can be an Axios Request Config or a URL string.

Last updated

Was this helpful?