Popularity
1.0
Growing
Activity
5.1
Declining
24
1
1

Monthly Downloads: 0
Programming language: JavaScript

axios-react alternatives and similar libraries

Based on the "Props from server" category

Do you think we are missing an alternative of axios-react or a related project?

Add another 'Props from server' Library

README

Axios React

NPM npm JavaScript Style Guide

HTTP client component for React with child function callback to creating 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, { Fragment } from 'react';
import Request from 'axios-react';

const Demo = () => (
  <Request
    config={{
      method: 'get',
      url: 'https://jsonplaceholder.typicode.com/todos/1',
    }}
    skip={false} // optional - default is false
  >
    {({ loading, response, error, refetch, networkStatus }) => (
      <Fragment>
          {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>
      </Fragment>
    )}
  </Request>
);

You can use the skip to disable send the request on the component mounting and you can resend the request using the refetch method every time.

Request config:

These are the available config options for making requests. Only the URL is required. Requests will default to get if the method is not specified. You can use all of the Axios request config options

Response schema:

The response for a request contains the Axios response schema.

Support: