Last active
September 23, 2015 11:05
-
-
Save Burning-Chai/00974087fdd4643eb273 to your computer and use it in GitHub Desktop.
This file contains 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
-- omission -- | |
var request = require('superagent'); | |
var React = require('react-native'); | |
-- omission -- | |
var AwesomeProject = React.createClass({ | |
render: function() { | |
return ( | |
<View style={styles.container}> | |
-- omission -- | |
<Button style={styles.btn} onPress={this._getWeather}> | |
What Weather in Tokyo?? | |
</Button> | |
<Text style={styles.instructions}> | |
{this.state.weather} | |
</Text> | |
</View> | |
); | |
}, | |
_getWeather: function(event) { | |
var self = this; | |
request | |
.get('http://api.openweathermap.org/data/2.5/weather?q=Tokyo') | |
.end(function(err, res){ | |
if (res.status == 200) { | |
self.setState({ | |
weather: res.text | |
}); | |
} else { | |
self.setState({ | |
weather: 'ERRRO!!' | |
}); | |
} | |
}); | |
}, | |
getInitialState: function() { | |
return { | |
weather: '' | |
} | |
} | |
}); | |
-- omission -- | |
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment