New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-api

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-api

A simple tool for fetching and handling data from an API with React

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

react-api

Build Status npm version

A simple tool for fetching and handling data from an API with React

Installation

Installing react-api in your Node project is simple:

$ npm install react-api --save

Usage

At its core, react-api is really just a simple React component. You would treat it as you would any other React component, with a few specific settings to keep in mind while configuring:

  • ref - string - Used to reference the component getting the API response.
  • url - string - The address of where you're getting your API response.
  • callback - function - A function for handling the actual response.

Examples

Here is a basic example of using react-api to get some data of a GitHub user's repositories:

const ReactAPI = require('react-api');

// The address of where to retrieve data
var URL = 'https://api.github.com/users/nickzuber/repos';

const MyAwesomeComponent = React.createClass({

  handleResponse: function(){
    // API response as a JavaScript object:
    console.log(this.refs.github.state.data);
  },

  render: function(){
    return(
      <div>
        <ReactAPI ref='github' url={URL} callback={this.handleResponse} />
      </div>
    );
  }

});

License

MIT

Copyright (c) 2015 Nick Zuber

Keywords

react-api

FAQs

Package last updated on 19 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts