You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-fetch

Package Overview
Dependencies
Maintainers
1
Versions
410
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-fetch

A component that fetches data from an api

0.0.9
latest
Source
npmnpm
Version published
Weekly downloads
895
-31.21%
Maintainers
1
Weekly downloads
 
Created
Source

##React Fetch

##Install

npm install react-fetch

##Props

  • url: where to fetch json data from
  • onSuccess: function on successfully fetching the data
  • onError: function to be called on error
  • options: object containing parameters for the request (see the fetch spec)

##Example

pass an api endpoint and the resulting object will be passed as a prop.


import React from 'react'
import Fetch from 'react-fetch'

export default class App extends React.Component{

  render(){
    return (
      <Fetch url="http://api.openweathermap.org/data/2.5/weather?q=London,uk">
        <TestComponent/>
      </Fetch>
    )
  }

}

class TestComponent extends React.Component{
  render(){
    console.log(this.props)
    return <div/>
  }
}
React.render(<App />, document.getElementById('app'));

###Rebuilding

Run this to view the example in example/dist

npm run build

Keywords

reactjs

FAQs

Package last updated on 27 Apr 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