Created
May 26, 2017 02:33
-
-
Save giancarlosisasi/8012d83fcba999d1cd55393bbeeb6d74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class App extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| data: undefined, | |
| }; | |
| } | |
| componentWillMount() { | |
| fetch('http://api.openweathermap.org/data/2.5/weather?q=London&APPID=f1af35f060fb74c410aa54ab5ae9d943', { method: 'GET' }) | |
| .then(response => response.json()) | |
| .then((json) => { | |
| const data = json; | |
| this.setState({ data }); | |
| }); | |
| } | |
| render() { | |
| const datos = this.state.data; | |
| console.log('state', this.state); | |
| return datos ? | |
| ( | |
| <div className="App"> | |
| { | |
| datos.weather.map(item => item.description) | |
| } | |
| </div> | |
| ) : (<h1>Loading</h1>) | |
| } | |
| } | |
| /*React.render( | |
| <App />, | |
| document.getElementById('react_example') | |
| );*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment