2.0.8 • Published 3 years ago

axios-react v2.0.8

Weekly downloads
270
License
MIT
Repository
github
Last release
3 years ago

HTTP client component for React with child function callback to create async requests in render based on Axios.

Installation

Yarn:

$ yarn add axios-react

npm:

$ npm i -S axios-react

Live example

Online Playground

Usage

import React from 'react';
import Request from 'axios-react';

const Demo = () => (
  <Request
    config={{
      method: 'get',
      url: 'https://jsonplaceholder.typicode.com/todos/1',
    }}
  >
    {({ loading, response, error, refetch, networkStatus }) => (
      <div>
          {networkStatus && <span>{networkStatus}</span>}
          {loading && <span>Loading...</span>}
          {error && <span>{error.response.data}</span>}
          {response && <h3>{response.data.title}</h3>}
          <button onClick={refetch}>Refetch!</button>
      </div>
    )}
  </Request>
);

Arguments

NameTypeDescription
loadingbooleanRequest loading.
responseobjectThe response for a request contains the Axios response schema.
errorobjectThe error for a request.
refetchfunctionRefetch method for a request.
networkStatusstringNetwork Connection Status.

Props

NameTypeDefault valueOptionsDescription
configobjectNoneAxios request config optionsConfig options for making requests.
skipbooleanfalsetrue or falseDisable sending requests when mounting the component.

Read more

Support

2.0.8

3 years ago

2.0.3

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.2

4 years ago

2.0.1

4 years ago

1.1.9

4 years ago

1.1.81

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago